Minor syntax changes

Howdy

Just wanted to let you know that I’ll be changing a few operators:

  • ' … pair
    • e.g. [ pair "a" 1, pair "b" 2 ] becomes [ "a"'1, "b"'2 ]
  • ~ … record access
    • e.g. rec ~ a
    • e.g. { a = 1 } ~ a
    • e.g. customer~address~city
    • e.g. my-rec ~ x
    • e.g. my-rec~x
  • ; … byte
    • ;ff
    • ;0A
  • ;; … bytes
    • e.g. ;;aG93ZHk=
    • e.g. $md5;;0782efd61b7a6b02e602cc6a11673ec9

Let me know if you have any thoughts/feedback!

Thanks for your patient support

1 Like

My take is obviously subjective, but, with regards to using ' for pairs, I feel like it may cause scrapscript code to be harder to read than it needs to be. Seeing " and ' juxtaposed makes my brain do a double take in order to reconcile what’s going on. I find that invoking pair as a function is clearer and more unambiguous.

I like the idea of using ~ for record access. It feels similar enough to the traditional record dot notation as to not be too overwhelming.

I think I’m somewhat neutral on the use of ; and ;; for singular bytes and multiple bytes respectively.

1 Like

Per our chat: I know you generally prefer to avoid keywords, but:

  • introducing where as a keyword (currently .)
  • using . for record field read (currently @)

would spend less of your language weirdness budget

1 Like

I think I prefer your other offline suggestion of using . for record access and , for “where”. But I do agree that we should mind the weirdness budget. I’ll write out some options and send em over soon

Thanks @max. After playing around with it, I think your suggestion to use . for record fields seems super solid.

And with that, I’m extremely happy with all syntax except the where operator. Here are some random thoughts/options:

  1. . is nice because it’s visually quiet and doesn’t require the shift key. But if . is used for record access, it creates ambiguity in operator power. Record access is very “tight” while where is very “loose”, e.g. a . a = { b = 2 } . b is a . (a = ({ b = 2 } . b)).
  2. ; is convenient but ugly as hell. It may also reduce weirdness points because semicolon is regularly used as a statement separator, i.e. a ; a = 1 seems pretty easy to understand for newcomers. This is probably the best choice given my other constraints. We could then use tilde for bytes again.
  3. ~ is not generally an easy key to reach but it’s aesthetically appealing, e.g. a ~ a = 1. I think this is what my heart wants, but my brain knows it’s a bad idea.
  4. , is convenient and very aesthetically appealing. But after trying it out in some toy programs, it feels clunky inside records/lists: [ 1, a, (b , b = 1) ] , a = 1

Any thoughts?