World: r3wp
[!REBOL3 Proposals] For discussion of feature proposals
older newer | first last |
BrianH 12-Nov-2010 [411] | SELFLESS? -> SELFLESS ? |
Ladislav 12-Nov-2010 [412] | No problem |
BrianH 12-Nov-2010 [413] | I did my best to argue for it by doing a thorough ticket and writing best-possible-without-it example code for LET and BIND-TO-NEW, to show how much it is needed. |
Maxim 12-Nov-2010 [414x2] | I really like LET |
especially when you put GET and SET besides it... all of a sudden I wondered... well, shoudn't LET have been the very first function evaluator :-D | |
BrianH 12-Nov-2010 [416] | Yup. I've been meaning to write a LET for years, but this has been the first excuse :) |
Ladislav 12-Nov-2010 [417x2] | Gregg: thanks for the "inverted programming" notion, I like it a lot. (used it in the #1758 comment) |
Brian, BTW, there is one reason why to prefer LET instead of CONTEXT: CONTEXT always yields the block it reates, while LET could yield a result that is wanted more. | |
BrianH 12-Nov-2010 [419] | I agree, especially when that is what you want more. SELFLESS is more comparable to CONTEXT. |
Ladislav 12-Nov-2010 [420] | err, block: :object, in my post |
Maxim 12-Nov-2010 [421] | Q: is the self word of a context something that can be bound to blocks within a method of that object? |
Ladislav 12-Nov-2010 [422x2] | did not understand your question probably; did you mean something like this? >> same? 'self first bind [self] make object! [a: 1] == false |
Or, maybe more in the line with what you wrote: make object! [method: func [block] [bind block self]] | |
Maxim 12-Nov-2010 [424x2] | yes that'ts it. |
because with SELFLESS it would be interesting! | |
BrianH 12-Nov-2010 [426x2] | >> a: context [a: 1] same? a first bind [self] a == true |
With selfless contexts it wouldn't work. In certain circumstances this can be useful. | |
Maxim 12-Nov-2010 [428] | but if SELFLESS simply ignored the self word, then self would be bound to object SELFLESS was called in... which is very nice to allow loops which can access contexts. |
Ladislav 12-Nov-2010 [429] | that does not look right to me at all |
BrianH 12-Nov-2010 [430] | Loops in OO code can be helpful :) |
Ladislav 12-Nov-2010 [431] | aha, maybe I misunderstood again |
BrianH 12-Nov-2010 [432x2] | Ladislav, you are right. >> a: context [a: 1] same? a first do bind [self] a == true |
Dammit. >> a: context [a: 1] same? a do bind [self] a == true | |
Maxim 12-Nov-2010 [434x2] | Q: would SELFLESS rebind values given with /set ? that is what I would expect, but its not defined in your ticket. |
though maybe its better if it didn't. | |
BrianH 12-Nov-2010 [436x2] | No, it wouldn't rebind the values. For that matter it doesn't bind the original words. |
It just uses SET semantics for the values. | |
Maxim 12-Nov-2010 [438x2] | I am thinking that SELFLESS could be used to build classes if we specified self as a word. |
since self could be set to another context... it would be interesting since a and self/a would effectively be different values :-) | |
BrianH 12-Nov-2010 [440] | Yup, though that is likely not as good an idea as other words other than self. Regular object self binding is really helpful for OOP, even class-based OOP. |
Maxim 12-Nov-2010 [441x4] | and since we have full control over the self word, because we are supplying/setting it then our class builder could properly bind the class methods to our instance selfless context. |
idea here is just that self is the accepted rebol term for object member setup. | |
the selfless object would be class and its self would point to the instance... something which is impossible with selfish contexts. | |
hum... nope, it would have to be the other way round. otherwise you can't safely have more than one instance per class. | |
BrianH 12-Nov-2010 [445] | Yup :) |
Maxim 12-Nov-2010 [446] | anyhow... I think that SELFLESS is an enabler. they allow us to evolve the language in specific domains while keeping the standard terms in our code. |
BrianH 12-Nov-2010 [447x2] | Added this to the SELFLESS ticket: "The values would not be bound to the context." |
Because that would be presumptuous and usually wrong :) | |
Maxim 12-Nov-2010 [449x2] | yes, like aggressive block evaluation :-) |
remember that mistake? ;-) | |
BrianH 12-Nov-2010 [451] | Not really, but that sounds like a bad one. Got to go now, later! :) |
Maxim 12-Nov-2010 [452x2] | I'm realizing that I coudn't really implement what I want. because the selfless? AFAIK isn't a state flag, its the actuall fact of having self inside. the code would still be subject to object's limitiations on the access of self, which means you can't set it. |
does context/make object! simply protect/hide the self word when it creates the context? | |
GiuseppeC 12-Nov-2010 [454] | You are able to make me feel so ignorant reading your discussion... |
BrianH 12-Nov-2010 [455x3] | Maxim, the self word in object contexts doesn't actually exist. The word self that you see is a keyword of the BIND function. A selfless context has a flag in it (that you can't set with MAKE object!) that tells BIND to not set that keyword. |
So if a selfless object actually has a real self field in it, it is still selfless. >> selfless? foreach self [1] [bind? 'self] == true >> foreach self [1] [bind? 'self] == make object! [ self: 1 ] | |
You can add a self field to a selfless context and it can be used like any other field. That is the whole point to selfless contexts. | |
Ladislav 13-Nov-2010 [458x3] | Added an alternative BIND/CREATE to the #1758 |
Regarding the above "self issue", I am still a bit at odds, whether it wouldn't be preferable to have it as in R2, where all contexts were selfless, objects just containing the word 'self. | |
I must be somewhat "dense" not understanding the benefits of the change. | |
older newer | first last |