Some comments after learning the language.

106 views
Skip to first unread message

Barney Wilks

unread,
Jan 14, 2018, 7:48:08 AM1/14/18
to Leaflang
So I've been playing around with leaf for about a week and these are some things I think are important for the language:
  • Need better error messages (really quite badly)
    • I think this is something that you're already aware of but it has probably been the biggest block in trying to learn the language (especially from a newcomers perspective, who doesn't know the in's and outs of the language)
  • This one is more of a comment, but I was wondering why the use of Unicode characters for type parameters ( 「/」 ) and internal namespaces (⁑) (although I haven't really come across the second one much). I would have thought that it makes sense to have standard ASCII characters that it is practically guaranteed everyone can type quickly and easily. I know that I had to fanny around with trying to get those characters to render for ages, and then having to configure special keyboard shortcuts just to quickly type a character (I configured 「/」 to Ctrl+[ and Ctrl+] for example). '<>' seems to be pretty standard syntax for generic types so that might make more sense (I think <: / :> can also be used however so I was wondering the thought behind that). 
  • The syntax for conditionals - it seems pretty strange to have to use 'do <condition> ? {} else | {}' instead of the common 'if <condition> {} else {}'. Personally I think the second one is better as it is more familiar.
  • Syntax for array indices - Again '<array>#<index>' seems a pretty strange syntax, especially considering '[ ]'  appears to be more common. 
I think that pretty much it off the top of my head. Most of these are syntactical things and don't make a huge difference to me, but I think they're worth noting.

Cheers,

edA-qa mort-ora-y

unread,
Jan 14, 2018, 8:07:51 AM1/14/18
to Leaflang
Better error messages: Yes, I agree. I'll work on this next after my current branch is done.

I'm using Unicode because ASCII doesn't offer enough options to properly delineate the types we need. The traditional overloading of < and > for templates is quite probelamtic in parsing, and can lead to ambiguities in the language. C++ has suffered from that, and has some weird workarounds.  I'm preferring to make this clean, even if it requires Unicode.  Unicode sequences will have ascii defaults, for parameters this is `<:` and `:>`, such as `array<: integer :>`.

There is no fallback for ⁑ as it's meant only for internal symbols. It's intentionally meant to look like something you shouldn't use in user names.  Only people working on the language will need it (that's the idea at least).


I might actually remove the `do` syntax. You can already use `then` and `else` syntax which is becoming the cleare alternative:

cond then {
   
true-code
} else {
   
false-code
}

I dropped the `if` to combine this with the short-form, such as `check_cond else return 1` or  `is_negative then a *= -1`


Array inidices don't use [] as I reserved those for tuples: which are much more frequently used and need a good paired syntax. For ambiguity it's important tuples don't share the same marker as blocks {}'s. The next most common index syntax is `#` which is used in HTML fragments. I also like that it doens't have a pair, since subscription is not related to a set in any way. That is, it shouldn't look like a value list (), tuple [], or block {} since it's in no way semantically related to such paired operations.
Reply all
Reply to author
Forward
0 new messages