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

World: r3wp

[Core] Discuss core issues

Maxim
26-Feb-2010
[15919x2]
I would love the /INTO refinement be added to all series manipulators.

This way we can make a huge buffer and reuse it all the time.
much less work for the GC and big speed gains on large series.
Steeve
26-Feb-2010
[15921]
UNIQUE is not used because of this.

I can't remember how many times i wanted an handy way to add unique 
values in an existing serie.
like 
>> unique index [new-values ...]
instead of having such, we do dirty tricks like.
>> unless find index new-value [append index new-value]  
pretty common...
Graham
26-Feb-2010
[15922x2]
didn't I suggest we have a set! datatype?
and yes, it's common to want to maintain a set ...
Maxim
26-Feb-2010
[15924x2]
steeve, that is what BrianH and I are talking about with the 'INCLUDE 
function.
basically, ALTER should disapear and be replaced with 'INCLUDE
Steeve
26-Feb-2010
[15926]
ALTER has no use except for Carl
Maxim
26-Feb-2010
[15927]
It should be renamed 'TOGGLE, and then I might use it, cause I'd 
understand what it means and think about it.
Gregg
27-Feb-2010
[15928]
INCLUDE isn't a good name for it, though, because of conflicting 
with the much more common INCLUDE for dependencies.
Izkata
27-Feb-2010
[15929]
If the set functions are made in-place, that would just be 'union, 
wouldn't it?
Steeve
27-Feb-2010
[15930]
Right, i was talking about UNION, not UNIQUE.
BrianH
27-Feb-2010
[15931]
Steeve, you are presuming that Carl has a use for ALTER - I haven't 
seen him use it yet.
Steeve
27-Feb-2010
[15932]
Is that not used somewhere in VID ?
BrianH
27-Feb-2010
[15933]
Not that I've noticed, but I seem to recall that VID flags is what 
ALTER was originally for.
Steeve
27-Feb-2010
[15934]
If that's so, Who's  asked for that clumsy function :)
BrianH
27-Feb-2010
[15935x2]
Gregg, we already have dependencies covered without using 'include. 
Using the word 'include has the advantage of discouraging people 
from reinventing the wheel, making yet another dependencies system.
Fortunately people can redefine the word as they like in R3, and 
it won't disturb existing code because of its module/dependency system.
Henrik
28-Feb-2010
[15937]
BrianH, in 2.7.7:

types-of :now

returns a lot of type blocks. Is that correct?
ChristianE
28-Feb-2010
[15938x2]
It returns nine blocks which correspond to the nine refinements the 
NOW function has. I guess it's somewhat intended behaviour ...
Refinement arguments are either of type NONE! or of type LOGIC!, 
so there is a reasoning.
Henrik
28-Feb-2010
[15940]
R3 does it too, so I suppose that is correct.
ChristianE
28-Feb-2010
[15941x4]
Yes, it is. And it makes sense:
>> apply :now [true none none none none none none none none]
== 2010
>> apply :now [none true none none none none none none none none]
== 2
>> apply :now [none true none none none none none none none]
== 2
>> apply :now [none none true none none none none none none]
== 28
>> apply :now [none none none true none none none none none]
== 13:26:18
>> apply :now [none none none none true none none none none]
== 1:00
>> apply :now [none none none none none true none none none]
== 28-Feb-2010
>> apply :now [none none none none none none true none none]
== 7
>> apply :now [none none none none none none none true none]
== 59
>> apply :now [none none none none none none none none none]
== 28-Feb-2010/13:26:47+1:00
(overfluous example no. 2 above)
With TYPES-OF you can decide about the argument ordering for APPLY 
and where to put the refinement switches.
BrianH
28-Feb-2010
[15945x3]
>> apply :now []
== 28-Feb-2010/6:58:05-6:00

Any arguments you leave off the end are passed the value none, at 
least in R3. That should be the case in R2 as well.
The blocks of types returned by TYPES-OF in R2 can be used mostly 
the same as the typesets returned in R3. The typeset! datatype was 
faked in R2 - see also the TO-TYPESET and TYPESET? functions. You 
can use them with FIND and the set functions, but otherwise be careful. 
Be sure to use the FOUND? function on the result of FIND to get the 
same result, which is TRUE? but not true. There are some built-in 
fake typesets too; look at the source of ANY-OBJECT? for an example 
of use.
Btw, that APPLY trick with the missing arguments is used in USE in 
R3 to initialize the words to none. The source:
use: make function! [[
    "Defines words local to a block."
    vars [block! word!] "Local word(s) to the block"
    body [block!] "Block to evaluate"
][
    apply make closure! reduce [to block! vars copy/deep body] []
]]
ChristianE
28-Feb-2010
[15948]
Regarding cutting off arguments, that was "just another" typo. The 
last should have been 8 NONEs ending in a TRUE for the /PRECISE refinement.
BrianH
28-Feb-2010
[15949x2]
Ah, that makes more sense.
Extra arguments in the block are ignored too, though the block is 
still reduced unless you use APPLY/only.
ChristianE
28-Feb-2010
[15951]
Oh, I never realised that USE is just a mezzanine ... cool stuff!
BrianH
28-Feb-2010
[15952x2]
>> apply :now array 20
== 28-Feb-2010/7:21:53-6:00
USE is a mezzanine in R3, a native in R2. They made the behavior 
of R2's USE into a function datatype: closure!. And then Ladislav 
and I backported closure! to R2 as a fake datatype (though USE doesn't 
use it).
ChristianE
28-Feb-2010
[15954]
Hm, I'm wondering if it would be useful if the position of the block 
provided could be changed to after the last argument consumed? That 
would allow applying one block to more than one function.
BrianH
28-Feb-2010
[15955]
The reference to the block provided is passed by value, not by name. 
You can't change the position of it, since position is a attribute 
of the block reference, not the block itself.
ChristianE
28-Feb-2010
[15956]
since position is a attribute of the block reference, not the block 
itself
 - that wasn't something I knew already ...
BrianH
28-Feb-2010
[15957x3]
However, that doesn't mean you can't advance the position yourself. 
Use LENGTH? WORDS-OF function to get the amount to advance, and be 
sure to reduce the block yourself and use APPLY/only so that the 
result is what you want.
Yeah, the position being an attribute of the reference is one of 
the core parts of series behavior in REBOL. In contrast, in R3 ports 
the position is an attribute of the port, not the reference to the 
port; same with OPEN/direct ports in R2.
This means that SKIP is a pure function for series, returning a reference 
to a new position - while it is modifying when applied to ports, 
changing the internal position. Same with the other position functions 
like AT, HEAD and TAIL.
ChristianE
28-Feb-2010
[15960]
I know such things when writing code, but more in a subconcious way. 
Of course different references to the same block having different 
positions doesn't go together with position being an attribute of 
the block (series) itself. That's of course obvious after only a 
little amount of thinking ;-)
Steeve
28-Feb-2010
[15961]
Wow ! I didn't noticed USE was not native anymore in R3...
Andreas
28-Feb-2010
[15962]
Also, USE is broken in R3 in as it captures RETURN and EXIT. See 
bug#539.
Steeve
28-Feb-2010
[15963x2]
Because USE make and do a closure! in R3 (which is a function).
Don't like that :-)
Look that alternate implementation of USE:

>> use2: funco [vars body][foreach :vars vars body]
>> use2 [a b][a: 1 b: 2  b + a]
== 3


The funny trick is that although the [a b] vars are locals to the 
block, we can pass values from the encompassing context.

>> a: 5
== 5

>> use2 [a][a: 1 + get a]
== 6

>> a
== 5
BrianH
1-Mar-2010
[15965x2]
USE is not broken because it uses closure!, it's broken because R3 
functions don't support something like the [throw] attribute yet.
Note the "yet" - that's intended to be fixed.
Geomol
1-Mar-2010
[15967x2]
ZERO?, TRUE? and coercion. I can't really deside what to think about 
these examples:

>> zero? 0.0.0
== true
>> 0.0.0 = 0
== false

>> true? 1
== true
>> 1 = true
== false

What do you guys think?
As ZERO is defined in REBOL, the first example could be:

>> zero? 0.0.0
== true
>> 0.0.0 = zero
== false