World: r3wp
[!REBOL3]
older newer | first last |
Ladislav 16-Mar-2010 [1593x2] | how about this, is it intended? >> f: func [self] [self] ** Script error: duplicate variable specified: self ** Where: make func ** Near: make function! copy/deep reduce [spec body] |
(that looks like illustrating your note, that 'self is a keyword) | |
BrianH 16-Mar-2010 [1595x2] | Nope, it is not intended, it is a bug. Report it. |
Only closures and FUNCT/with should define 'self; regular functions shouldn't. | |
Ladislav 16-Mar-2010 [1597x2] | Why closures, is it of advantage for closures? |
(I do not see it as an advantage, maybe overlooking something...) | |
BrianH 16-Mar-2010 [1599] | The contexts of closures persist outside of the scope of their execution, like objects. The contexts of functions don't. |
Ladislav 16-Mar-2010 [1600x2] | yes, I know that, but does it need to use 'self because of that? |
(my closures originally did not use 'self) | |
BrianH 16-Mar-2010 [1602] | Not unless the closure has no arguments, but it doesn't hurt enough to get rid of it. On the other hand, we should probably get rid of 'self binding from FOR, REPEAT, FOREACH, MAP-EACH and REMOVE-EACH (it's already been reported). |
Ladislav 16-Mar-2010 [1603] | yes, that looks inappropriate |
BrianH 16-Mar-2010 [1604x2] | I would be willing to accept getting rid of 'self binding from closures if that is the choice, no big deal. |
The 'self bound by FUNCT/with is bound to the object context, so it should stay. | |
Ladislav 16-Mar-2010 [1606] | 'self binding from FOR, could you point me to the ticket? |
BrianH 16-Mar-2010 [1607] | Weird, can't find it. I remember someone reporting it - must have been in chat. Report it. |
Ladislav 16-Mar-2010 [1608] | OK |
BrianH 16-Mar-2010 [1609] | I would myself but don't have the time today (friend in hospital). I can refine any tickets later if you like. |
Ladislav 16-Mar-2010 [1610] | OK, no problem |
BrianH 16-Mar-2010 [1611] | It seems that functions don't bind 'self to the code block, but they do reserve it in the function spec. So that's a separate ticket. |
Ladislav 16-Mar-2010 [1612] | yes |
BrianH 16-Mar-2010 [1613x3] | And closures don't bind 'self anymore either (I now vaguely remember a ticket related to that). |
Note: The duplicate variable 'self bug in function and closure specs might be dismissed (not by me). It could be necessary for the implementation to have an internal 'self in the function contexts; only Carl could say for sure. | |
That seems like more of a gotcha than a bug though. | |
Ladislav 16-Mar-2010 [1616x3] | >> g: func [] [self] >> same? 'self first body-of :g == false |
hmm, seems to be used | |
how about the #447, it does not look like accepted to me? | |
BrianH 16-Mar-2010 [1619] | It's not rebound by the function. What you are seeing is the script context. |
Ladislav 16-Mar-2010 [1620] | >> a: 'self == self >> b: 'self == self >> same? a b == true |
BrianH 16-Mar-2010 [1621x3] | Right. Scripts all use the same default context: system/contexts/user. |
Modules get their own contexts. | |
>> same? self system/contexts/user == true | |
Ladislav 16-Mar-2010 [1624] | then, what makes the difference in the above case of the function body? |
BrianH 16-Mar-2010 [1625x2] | The 'self word you are comparing is not bound to the function context, it is bound to the script context. |
Or whatever other "outer" context 'self is bound to depending on where the function was defined. | |
Ladislav 16-Mar-2010 [1627x2] | >> a-body: [self] == [self] >> g: func [] a-body >> same? first a-body first body-of :g == false |
so, something has to happen when the Func is called | |
BrianH 16-Mar-2010 [1629] | No, something happens in BODY-OF - the words are unbound in the copy of the body returned, for security purposes. |
Ladislav 16-Mar-2010 [1630x2] | right, sorry |
>> a-body: [first [self]] == [first [self]] >> g: func [] a-body >> same? first second a-body g == true | |
BrianH 16-Mar-2010 [1632] | >> a-body: [self same? first a-body 'self] == [self same? first a-body 'self] >> g: func [] a-body >> g == true |
Ladislav 16-Mar-2010 [1633] | and how about #447, do you consider it solved? |
BrianH 16-Mar-2010 [1634] | Yeah. It must have been reported by that other BrianH :) |
Ladislav 16-Mar-2010 [1635x2] | which one? |
LOL | |
BrianH 16-Mar-2010 [1637x2] | I use that joke in the tickets when someone doesn't realize that they are reporting the same bug twice :) |
Just checked: I have reported 1/6 of the R3 tickets in CureCode. | |
Ladislav 16-Mar-2010 [1639x2] | , which is probably less, than what Meijeru has reported? |
(amazing) | |
BrianH 16-Mar-2010 [1641] | It's harder for me to get the proportion of Meijeru's tickets - I have to count tickets rather than pages. |
Ladislav 16-Mar-2010 [1642] | nevertheless, shouldn't #447 be marked as still not solved? |
older newer | first last |