3 ms·
At first glance I love this syntax. I'll have to pull out some of my hypothetical syntax notes to see if any holes I came up with for my language attempts apply
by webjprgm 13y ago
At first glance I love this syntax. I'll have to pull out some of my hypothetical syntax notes to see if any holes I came up with for my language attempts apply here, but I very much like it.
Using high-level function constructs for main language flow control features seems to be in vogue. Rust does it too. I liked it when I learned Scheme and have been wanting it to be more main stream since then. That's probably why I like Ruby, since Ruby's blocks are close for many uses.
I'll play with this more when I get home tonight.
- webjprgm 13y agoI did a little playing with it last night. I find that one can do object-oriented things, but constructors are a bit of a catch. struct A : [a, defaulted] struct B : A [b] //You can do it this way, //but each subclass has to init every field (brittle) function MakeA(a): [a, 99] : A function MakeB(a,b): [a, 99, b] : B //Or use the super constructor syntax //but this uses a copy and is less efficient function MakeA(a): [a, 99] : A function MakeB(a,b): [super MakeA(a), b] : B //Or something in between function InitA(me::A, theA): a = theA; defaulted = 99; me function MakeA(a): new := [0,0]; new.InitA(a) function InitB(me::B, theA, theB): me.InitA(theA); b = theB; me function MakeB(a,b): new := [0,0,0]; new.InitB(a,b) I'll keep playing with it and see what else I discover. I haven't gotten far enough to use coroutines, multi-method, or to make my own control structures yet.
- Aardappel 13y agothe second option is the intended one, yes. I'd only switch that out to first one if you ever found that allocating objects is the bottleneck in your code, which it shouldn't be.