r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Proposals] For discussion of feature proposals

BrianH
13-Nov-2010
[490]
Other than that and a couple tweaks to fix similarly minor bugs here 
and there, it could be used in the ticket as-is.
Ladislav
13-Nov-2010
[491]
OK
BrianH
13-Nov-2010
[492x2]
I also noted in a comment that a native LET could be used to implement 
a mezzanine SELFLESS, just as easily as the other way around.
Since LET would be used directly more often than SELFLESS, native 
LET might be the better option.
Ladislav
13-Nov-2010
[494]
That is what I think as well
BrianH
13-Nov-2010
[495x4]
Fully mezzanine LET is still too inefficient to implement USE, but 
the same technique could be used in USE if we went with definitional 
return.
However, this is still slower than APPLY closure in my tests.
Wait, you can't implement SELFLESS with native LET. The empty context 
would still not work.
Added the SELFLESS using LET code to the SELFLESS ticket.
Ladislav
14-Nov-2010
[499x3]
Giving the 'self issue in objects another thought. It occurs to me, 
that we could be better off not having it at all, i.e. having all 
contexts seflless. An object method can refer to the object without 
using 'self anyway. E.g.:

o: make object! [this: does [bind? 'this]]
same? o o/this
== true
Or:

>> o: make object! [this: bind? 'this]
== make object! [
    this: make object! [...]
]
This would simplify the whole SELFLESS, SELFLESS?, LET, etc. issue 
as well
Anton
14-Nov-2010
[502]
Aha, full circle. I seem to remember SELF was added by user request, 
and now it might be removed to simplify things. If I could remember 
why the user(s) wanted it...
Ladislav
14-Nov-2010
[503x2]
When was it added?
In my opinion, it must have been before the BIND? function were available
Anton
14-Nov-2010
[505x2]
Oh, long before that.
Maybe around 2001, on the mailing list.
Pekr
14-Nov-2010
[507]
IIRC there was a long discussion about SELFLESS functionality, it 
was imo backed mainly by BrianH, whereas some other members did not 
regard it being much important.
Ladislav
14-Nov-2010
[508]
How about the LET function, Pekr, would you find such a function 
useful?
Pekr
14-Nov-2010
[509]
I haven't read those proposals yet ... might do so this evening - 
I am simply behind ...
Anton
14-Nov-2010
[510]
LET would be useful to me.
Henrik
14-Nov-2010
[511]
I'm unclear on LETs value. Can someone provide a useful example?
Ladislav
14-Nov-2010
[512]
Writing some, just a moment
Henrik
14-Nov-2010
[513]
Thanks
Ladislav
14-Nov-2010
[514x3]
http://www.rebol.net/wiki/Exception_proposals#LET_2
Now it only depends whether you find those examples "useful". You 
can find other examples in the article, though.
(and they *are* useful)
Henrik
14-Nov-2010
[517]
Well, I think it would be clearer to see it applied in loops and 
using multiple values. As it is shown there, USE and DO FUNC are 
clearer to me. It may be very useful.
Ladislav
14-Nov-2010
[518x2]
You find this example:


    x: 121 print ["result:" use 'x [x: system/contexts/user/x x: x + 
    1 x / 2 + x]]


clear? Even knowing, that it actually does not work if not in user 
context?
As far as the DO FUNC examples go, they are just equivalent to the 
LET examples, as is quite obvious. The distinctions are rather small, 
like the fact, that you do not need to create a function and then 
call DO
Henrik
14-Nov-2010
[520]
Clarity: That depends, because the example is contrieved as a "trap": 
I have little base for judging it.
Ladislav
14-Nov-2010
[521x2]
contrived example - you never encountered a situation, when you wanted 
to keep the outside variable unharmed, using a local variable with 
the same name?
maybe not, it is not that frequent
Henrik
14-Nov-2010
[523]
the case would be that 'x is defined dynamically. I suppose I'm confused 
by the use of system/contexts/user/x. would you call the user context 
'x that way?
Ladislav
14-Nov-2010
[524x2]
I am not sure I understand your question
just run the example in the interpreter
Henrik
14-Nov-2010
[526]
Nevermind. I think I can see it now. Regarding DO FUNC, I suppose 
the advantage should be less overhead with LET, if possible. Otherwise 
I see it as shuffling arguments around.
Ladislav
14-Nov-2010
[527x2]
less overhead for the user (does not have to call DO), less overhead 
for the interpreter (does not have to create the function), and a 
couple more quirks like RETURN and EXIT handling
in essence, LET is the same as USE, just with the variables being 
initialized as needed
Henrik
14-Nov-2010
[529]
ok, it passes for me.
Ladislav
14-Nov-2010
[530]
in R3, USE VARIABLES BODY is equivalent to LET VARIABLES NONE BODY, 
while in R2 USE VARIABLES BODY is equivalent to LET VARIABLES #[unset!] 
BODY
BrianH
14-Nov-2010
[531]
The BIND? function was added partly to deal with the security issues 
with R2's self. You can't as easily spoof BIND?.
Maxim
15-Nov-2010
[532]
on the question, why do we really need self:


self is very usefull when you use objects within code, because there 
can often be binding clashes.   self assures one that a parameter 
is always from the context and not from the function.

self.x: x


has occured pretty often for me.  its also very usefull when you 
need to return the context from which a function was bound.  
I also use it to do indirection: 

obj: self
context [
	parent: obj
]


remove self, and we can't say that REBOL has objects anymore.  many 
things will become really complicated for no reason.
Ladislav
15-Nov-2010
[533x3]
Yes, I can understand, where the first one becomes handy, but it 
can be done easily in selfless contexts as follows:

[
    self: bind 'self
    ...
    self.x: x
]


The second one is actually more annoying having implicit self, than 
it would be otherwise:

[
   class- name: 'my-name
    context [
        parent: bind? class-name
    ]
]
sorry, I meant BIND? not BIND above
But, nevermind, take it just as a comparison...
Maxim
15-Nov-2010
[536]
yeah, but using bind is an inherently advanced use.  though like 
you, I understand that its just comparison.  


I'm in favor of 'SELF simply because I woudn't want REBOL code to 
become riddled with binds for such simple things. 


AFAIK bind doesn't scale well, in the sense that when you are playing 
around a lot with your code, bind will often become a point of failure, 
since the littlest change will quickly change what BIND does.
Ladislav
15-Nov-2010
[537x2]
This is not BIND, just BIND?
(sorry again)
Maxim
15-Nov-2010
[539]
oooh... sorry I didn't see that nuance (my fault) ... I didn't even 
realize we had bind? in R3.   hum.  this opens up many doors.  I 
think my mind mistook every use of BIND? as a  call to  [ not not 
BIND? word].  

(like   found?  vs  find)