Open towerofnix opened 8 years ago
Eh, just copy JS. :package: Easiest way to do it.
If we copy js, we could make the interpreter very small and lightweight!
eval("<tulun here>")
If people want to do the JS expression foo[bar[baz]]
, then they should do bap => bar:baz; foo:bap
in Tulun. We don't want to copy JavaScript yet again...
The thing is, o[k1[k2]]
makes more sense.. plus it doesn't need an extra variable. Which is better?
o[k1[k2]]
# or #
k_ => k1:k2;
o[k_];
Suppose I want to access o[k1[k2]]
in an expression? I can't define variables in an expression! I'd need to do something like this:
print({ k_ => k1:k2; return(o:k_); }()); # inline function creation then evaluation #
Does that really seem any better than this..?
print(o[k1[k2]]);
Hm... ooh, maybe offer both styles? We may as well :package:
Hm... ooh, maybe offer both styles? We may as well :package:
I'm only really interested in including good features, and I don't see how you can consider this good.. :P
print({ k_ => k1:k2; return(o:k_); }());
I dunno, it's just that copying js seems like cheating
Perhaps looking at how other languages work with object-access-by-keys might inspire us?
EDIT:
Python and JavaScript do it like so:
obj_or_equivalent[key]
Ruby looks to be pretty much the same:
puts "#{hash[key]}"
...well then. I guess obj[key]
it is :|
We should probably make the syntax less javascripty, though.
Racket and Java each have their own functions, e.g.
my-hash-map => make-hash-map()
my-hash-map.set('bar', 'baz')
my-hash-map.get('bar')
We should probably make the syntax less javascripty, tho
+1 this. Any ideas on how to make it less JS-y? So far the best I think I've done is #34 :P
How about this?
foo => obj();
foo.bar -> obj(
'hi', 'Hello there!' # this needs to be implemented soon! #
);
foo:'baz': -> 'bar';
foo:('b' concat 'ar'):.hi # Hello there! #
# : is equivalent to [ and ], basically #
Kinda important.
I'd like this:
But the problem with that is the ambiguity when you have multiple
:k
s..Is that "k2 of (k1 of o)" or is that "(k2 of k1) of o"?
Probably the easiest thing to do is make the syntax like this instead:
If we do that we don't even need the colon any more:
Aaaaand now we're copying JavaScript again! :tada: