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
[476x5]
And you might want to get into the habit of using CAUSE-ERROR, since 
it makes your code look simpler and hides the differences between 
R2 and R3 errors.
I just realized something: You don't need word references to have 
the full power of PARSE, you can use circular direct references instead. 
Of course you can't specify those structures in loadable source, 
you have to construct them dynamically, and you can't BIND them so 
you stiff can't use definitional scope for its operations. But it 
is at least in theory possible to match the patterns that finite 
nested rules can't match by using circular structures.
stiff -> still
Really awkward to do so though, and you can't just see the structure 
in source so it is harder for many people to understand.
Overall, the best and most efficient strategy for dealing with the 
problems of circular structures is to not use them, or to accept 
that they will have problems. Having *every* object have a circular 
reference in it was a bad idea because of that. Using word references 
instead of direct references is another way to deal with the problem 
though.
Ladislav
13-Nov-2010
[481]
Word references - yes, that is fine
BrianH
13-Nov-2010
[482x4]
Added a REBOL-code almost-equivalent to the SELFLESS ticket, based 
on your trick, and a couple minor bug fixed. Rewrote LET to use the 
same trick. Strangely enough, the LET version has less overhead than 
the SELFLESS version of the same trick, especially in the error handling 
code. The LET function is now efficient enough to be acceptable as 
a mezzanine function, though not yet efficient enough to be used 
to implement low-level mezzanine functions.
You got the arguments to your error wrong :(
No big deal though.
We could really use a native LET or SELFLESS - either would do, actually, 
and could be used to implement the other.
Ladislav
13-Nov-2010
[486x2]
Yes, "your error" - which one?
aha, yjou mean the implementation of SELFLESS
BrianH
13-Nov-2010
[488x3]
Yup. Compare the arguments to CAUSE-ERROR in the ticket version of 
SELFLESS.
Your second argument should be 'words instead of 'any-word.
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