-
Notifications
You must be signed in to change notification settings - Fork 1
Specification Flaws #4
Comments
Yeah, I can do that. It's the only grammar syntax I'm familiar with.
I agree that too much shortening is not useful, but I think Int is a special case - all the C based languages (as far as I know) and Kotlin use
Good point. I'll add a detailed description.
Will do. You make some interesting points regarding the
You suggested using Incidentally, the same problem would arise with the syntax
Are we creating a shadowed variable Frigga (the previous language I designed) used this syntax and I found it caused more problems than it solved. In my opinion the only viable alternative to
I guess this one is personal preference. My reasoning behind this syntax is that functions would be declared identically to lambdas, therefore making learning the language easier and a more consistent syntax (since functions are just lambdas with a name). If there was a different syntax, let's say something like
While it might be clearer, this raises a few other problems:
I think the reasoning here is that "subtyping" isn't true subtyping. The extend syntax was originally for defining extension functions, but we decided later on that pseudo-inheritance would be useful too. The easiest way to do this, we thought, would be inside the Regarding the type parameter syntax, I think Overall you make some good points, but I think the majority of the changes would either make the language more inconsistent, or add an extra degree of complexity to reading and learning the code. |
I'd imagine that |
We're nowhere near to creating a standard library yet, however yes, the reasoning behind Int is similar to Kotlin's: familiarity for people familiar with C based languages, while not having 2 different types of type |
Elara Language Specification
Would definitely be worth linking to antlr's documentation, as personally, I don't fully understand this specification (my points below are made from educated guesses, or examples), and I assume others may not either.
Names and conventions
Short and simple, yet you've got
String
there? Why notStr
? IfString
is necessary, why notInteger
? Just not a fan of integer being shortened, while other types aren't. For example, in java, integers are the only primitive type that are shortened, whereas all the other primitives, and their wrappers, use the full word. There's absolutely no reason why this should be the case. Not to mention, shortening like that is never useful imo, and usually just results in less readable code.For multi-word identifiers. Also, it's important to note, that-this-format-of-text, is not universally recognised as kebab-case, unlike other formats, for example camelCase. While honestly, it's obvious what kebab-case is, perhaps a specific definition of it would be appropriate, merely for absolute clarification.
Types
Consider making a glossary, for jargon like this.
Simple Syntax
There's is a fundamental inconsistency with this syntax. As far as I can tell, two points can be argued here. The first, is that this statement is a mix of traditional programming syntax, and english itself. Before continuing with that argument, I need to make an important distinction clear, obviously languages borrow a plethora of words from english, however they have absolutely no syntactical value, they are merely keywords. The syntax would not be affected whatsoever if said keywords were replaced with collections of symbols from other languages.
So, the actual first argument, we've got a mix of traditional programming syntax, and english. The english part of this expression, is the
let
keyword. Now, you could argue my point from before, that this is merely a "borrowed" word from english. The problem with that counter argument though, is that the borrowed words I mentioned before always make sense in the actual code. For example, in kotlin, you've got var/val, which represent variable/value. let, has absolutely no meaning unless you consider this statement as an english sentence, instead of code. The only thing I could think of that let could represent, is letter, but obviously that's not the use case here. The traditional programming syntax here is the use of=
, which is why I consider your syntax inconsistent. To be consistent, = could either be changed tobe
, orequals
, to match that of the english language, OR,let
could be changed to a more appropriate keyword; my vote is.... drumroll, none at all ([name] = [value]
)!Perhaps all of the above is redundant, because you were simply following the syntax of arguably the most universal language? mathematics.
let [name] = [value]
is undoubtedly recognisable as mathematical syntax, so, if that's the case (elara's syntax is equal to that of mathematics), then surely we'd expect that the rest of Elara's syntax is equal to it's mathematical counterpart? Well, obviously this isn't the case. Jumping ahead a bit, to the function syntax,this obviously doesn't follow mathematical syntax. In fact, mathematical syntax doesn't even have a direct alternative to the above, the only part you could (mind you, partially) recreate is the function declaration (
f(x) = ?
), but none of the encased logic.I'm well aware that
let
isn't unique to this language, it's quite universal in fact, finding it's way into many other languages, including swift, and javascript. This does not excuse it's terribleness though.This isn't from the spec, rather from an example, but as I mentioned before, I don't really understand the spec, so it's easier for me to comment on this. IMO, this is quite a mouthful. To start off with, the let argument from before also applies to this, and my personal recommendation is to simply not have any prefixing keyword. Apart from that, just generally not a fan of the syntax,
= [type] => {logic}
, it's ugly. Don't have any suggestions either for it sorry, perhaps consider something more traditional.Structs
I don't understand the format, can we get some comprehensive examples?
Generics
Another little inconsistency. Earlier, structs were extended using
extend
, yet generics use:
to represent the generic as a subtype of the specified type.Need sleep, might expand on the above two seconds tomorrow, or might not, idk.
The text was updated successfully, but these errors were encountered: