Not really a bug, but I accidentally discovered that '!' now gets replaced with 'self' at runtime, except when followed by '=':
> !ish = 42 > ?selfish 42 |
This is a bit confusing because in other languages, ! is an operator, whereas here it behaves almost like any other letter.
Whaaaaaaaaaaaaaaaaaaaaaaaaaaaaat.
The "!ish" behaviour is odd but "!.x = 3" is nice.
I'm starting to wonder whether 0.2.0 has more... secret syntax.
yep, bad idea.
not sure what the deal is with "self" anyway. it's just a very tiny convenience, you don't have to use it.
o = { set_a = function(m,x) -- explicit m as "self" m.a = x end } function o:set_b(x) -- implicit self self.b = x -- <-- you really asked for it end function o.set_c(m,x) -- explicit m as "self" m.c = x end -- o passed as implicit "self" o:set_a(1) o:set_b(2) o:set_c(3) ?o.a..o.b..o.c -- explicit "self" o.set_a(o,3) o.set_b(o,2) o.set_c(o,1) ?o.a..o.b..o.c |
"m" or whatever, just use a cat glyph instead...
This was something I'd asked for in the past. I actually asked for $ as short for self, but I guess $ as peek4 already existed.
I suspect the fact that it's not delimited properly is just a bug.
Also I wouldn't consider it a done deed. I think there's a reason why it's undocumented. Last I heard, zep wasn't sure if he liked the idea either. You might want to hold off on using it.
It's true you can define your own name for self, but it does require using the full dotted or inline prototype for methods. With this alias, you can still define blah:method() and it'll just work.
[Please log in to post a comment]