Log In  

Not really a bug, but I accidentally discovered that '!' now gets replaced with 'self' at runtime, except when followed by '=':

> !ish = 42
> ?selfish

This is a bit confusing because in other languages, ! is an operator, whereas here it behaves almost like any other letter.

P#75065 2020-04-20 21:34

The "!ish" behaviour is odd but "!.x = 3" is nice.
I'm starting to wonder whether 0.2.0 has more... secret syntax.

P#75096 2020-04-21 05:29

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

function o:set_b(x) -- implicit self
    self.b = x      --  <-- you really asked for it

function o.set_c(m,x) -- explicit m as "self"
    m.c = x

-- o passed as implicit "self"

 -- explicit "self"

"m" or whatever, just use a cat glyph instead...

P#75109 2020-04-21 11:51
:: Felice

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.

P#75125 2020-04-21 17:08 ( Edited 2020-04-22 05:00)
:: Felice


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.

P#75126 2020-04-21 17:09
:: Felice

And it's gone. Ah well. :)

P#75293 2020-04-24 15:05

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-08-05 03:58:41 | 0.020s | Q:19