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

World: r3wp

[!REBOL3]

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
[1642x2]
nevertheless, shouldn't #447 be marked as still not solved?
- taking into account, that your comments still apply...
BrianH
16-Mar-2010
[1644x2]
No, it's solved. The bug was binding 'self in the code block, which 
it used to do and now doesn't (as of alpha 50).
The 'self in the argument list duplicate word bug is separate.
Ladislav
16-Mar-2010
[1646]
OK, checked, and you are right
BrianH
16-Mar-2010
[1647]
I would be willing to accept getting rid of 'self binding from closures 
if that is the choice, no big deal.
 (from above here)
Ladislav
16-Mar-2010
[1648]
aha, that was "the other BrianH"
BrianH
16-Mar-2010
[1649]
:)
Pekr
19-Mar-2010
[1650]
.... all fronts are so silent ....
amacleod
19-Mar-2010
[1651]
indeed
Henrik
19-Mar-2010
[1652]
The most "action" seems to be in R3 GUI documentation here: http://www.rebol.com/r3/docs/gui/gui.html
Pekr
19-Mar-2010
[1653]
I noticed the docs are getting a bit prettier too ... some icons, 
images, right panel menu, etc.
Henrik
19-Mar-2010
[1654]
>> extract/index [a b c d e] 2 2
== [b d none]

Is the last NONE desirable?
Steeve
19-Mar-2010
[1655]
Surely not, but it''s so easy to make your own that i don't see the 
interest to have such mezz :)
Henrik
19-Mar-2010
[1656]
R2 and R3 do the same.
Steeve
19-Mar-2010
[1657x3]
It's the problem with such mezz, they are allowing to much refinements 
so that it ended all messed up :)
By example, the refinement /index has absolutly no interest.

The obvious and regular way with rebol, is to use SKIP or AT as a 
prefetch.
see.
extract/index [a b c d e] 2 2
vs.
extract at [a b c d e] 2

the second one is faster and even shorter to write :)
Henrik
19-Mar-2010
[1660]
fair point
BrianH
19-Mar-2010
[1661x4]
Henrik, the /index option of EXTRACT assumes that there will be something 
there at the index (record length specified is assumed), and that 
the R3-style treatment of series bounds is in effect. That means 
that the programmer is expected to do their own bounds checking, 
or to not care. The none value is a placeholder for missing data.
Steeve, the second example you gave was missing a 2 on the end. But 
still, if that is the answer you want then that is a good way to 
do that. However, since EXTRACT is used for field extraction fron 
fixed-length records, Henrik's code is correct for that use. He just 
forgot to put a value in the proper place in the third record, so 
it returned none.
Your method didn't return a value at all, as if the whole record 
was missing; not the same thing at all.
As for the reason for the inclusion of the EXTRACT function and its 
/index option, it is because of how much they are used, even in mezzanine 
code. There are a lot of functions there for our convenience, even 
if they would be easy to remake if missing. This doesn't make them 
less useful.
Henrik
20-Mar-2010
[1665]
Actually, I used it on a table header with arbritrary data and simply 
wanted every second element in the block, regardless of the block 
content, so the block was not a db record of any known length. Perhaps 
it should be emphasized that extract/index works best on, or is intended 
for database records.