by dlsym · 13y ago · 0 comments
Interesting language though.
It more resembles LISP with its macros and closures with nice syntax built around those concepts.
I tried to make all the operators match their closest arithmetic, mathematical equivalents. Thus using `^` for exponent and `+` for addition. Since JavaScript does not support bitwise operators cleanly, needing to cast to int32 and generally being disued, I felt they could be better aliased with `bit`, freeing up those operators. Since string concatenation needed some operator as a building block for string interpolation, the freed-up `&` was a ripe candidate for it.
That all said, string interpolation is the typical use case for creating strings, so feel free to just use that if possible. Anything more than that and you might need a templating engine.
var 1 = 5+5 // I would expect: Error 0-9 cannot be used as a variable
var foo = "Hello " "Bob!" "\nAre you there?"
var bar = "Hello " 1
console.info(1) // throw error and refer to var 1
console.info(foo)
"Hello Bob!
Are you there?"
console.info(bar)
"Hello 1"> Thus using `^` for exponent and `+` for addition
That is good in my eyes.
Of course you can say that since it is defined as such, it's not a issue, but then we could say that any Javascript "Wat" behavior is also defined in the spec.
Personally, I like Perl's period(.) for string concatenation, but I think it can too easily get lost in the line, especially for more complex stuff.
$foobar = "foo" . $bar->{'bar'}I didn't want to have `~` mean string concat because it overloads the semantic meaning of what `~` would represent.
I actually stole `&` from VB, as well as `\` as floor division.