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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
22-Mar-2008
[9489x2]
Lastest Makedoc draft of TRETBASE for public download:

http://www.mediafire.com/?x8yu1mrl724
sorry wrong group
RobertS
23-Mar-2008
[9491x2]
; I liked this feature of ICON/UNICON where a func can have an initially 
block so I have this in REBOL
initial: func [wd [word!] /list /local functions]
  [
    functions: []
    if list [return functions]
    f: find functions wd
    either (found? f) 
      [return false] 
      [append functions wd return true]
  ]    


initially: func ['wd [lit-word!] blk [block!]][
    if (initial wd) [do blk]
]
; and to test initially
test: func [str [string!] /local prefix [string!]][
    prefix: ""
    initially 'test [prefix: "tested "]
    print [prefix str]
]
; which runs as, say
test "this"
; first time giving "tested this" and thereafter "this"
; thoughts on whether useful enough to go into the org library ?
; of course initial itself test more simply
>> initial 'append
== true
>> initial 'append
== false
BrianH
23-Mar-2008
[9493x2]
Paul, the changes to EXTRACT are part of a whole series of subtle 
changes to REBOL that are based on 3 ideas:

- NONE is a value that denotes no value, like UNSET but not an error 
- sort of like SQL NULL.

- Out of range isn't necessarily an error - you can choose to treat 
it as such as you like, or not. Boundaries are really an implementation 
detail in a language with autoexpanding series. The choice to have 
fixed boundaries is left to the developer.

- There is no difference between a NONE in the middle of a series 
and a NONE off the end. It's a missing value either way.


REBOL worked this way already in many cases, so we're making it more 
consistent.
Creating, evaluating, throwing and catching those error! values is 
really expensive - nones are much faster. Also, these error! values 
are generated in many cases now where the situation isn't really 
erroneous, which is a little presumptuous.
[unknown: 5]
23-Mar-2008
[9495x3]
I just don't like it Brian.  Like Henrik noticed I have a problem 
with it because it returns none as a value inside of the series. 
 I rather have it report none as a none! When it is reported as it 
is currently in extract it isn't a none! datatype it is a 'none word 
value.
Skip+ does it find BrianH and I don't have to catch any errors.
And it returns a none datatype if out of range.  I don't have to 
check for "out of range" as the none being returned tells me that.
BrianH
23-Mar-2008
[9498]
Sorry, I don't get something. Are you saying that EXTRACT is returning 
the word 'none rather than the value #[none], or that you are using 
the word 'none in your series for something else?
[unknown: 5]
23-Mar-2008
[9499x2]
It is returning the none in the block when I could actually already 
be using the word none in the block
So if I'm using 'none in the block and it is returning #[none] then 
I have to check to determine if the value returned is a none! or 
a 'none.
BrianH
23-Mar-2008
[9501x2]
Let's make a distinction here: The word 'none, the value #[none]. 
EXTRACT returns the value #[none]. What are you using 'none for?
Sorry, AltMe is locking up on me again. I wrote that message 2 minutes 
ago.
[unknown: 5]
23-Mar-2008
[9503]
Sometime I use the value none to specify that position in the series 
doesn't currently have a value.   I'm sure many have done this.
BrianH
23-Mar-2008
[9504]
That is how EXTRACT treats #[none], every time.
[unknown: 5]
23-Mar-2008
[9505]
Brian did you create the EXTRACT function or something as I can't 
see how anyone would prefer its return value over a simple return 
for general use.
BrianH
23-Mar-2008
[9506]
So your problem isn't with EXTRACT treating #[none] as no value, 
it's with it treating out-of-bounds as a non-error.
[unknown: 5]
23-Mar-2008
[9507x2]
Both
Did you try the skip+ function from above?
BrianH
23-Mar-2008
[9509]
I looked at skip+ above and could see from the code what it does.
[unknown: 5]
23-Mar-2008
[9510x2]
Notice here:

>> a
== [1 2 3 4 5 6 7 8 9 10]
>> skip+ a 2 1
== [1 3 5 7 9]
>> skip+ a 2 11
== none
Simple from its output I can tell that the index was out of range 
by the none that was returned.  Can't tell that from extract.
BrianH
23-Mar-2008
[9512]
Re "Both": You said that you treat #[none] as no value, even in the 
middle of a series, and that is what EXTRACT does, so no, that is 
not your problem.
[unknown: 5]
23-Mar-2008
[9513]
BrianH did you create the Extract function?
BrianH
23-Mar-2008
[9514x2]
As an aside, whenever someone posts a message to AltMe my client 
locks up for 30 seconds to a minute, making it impossible for me 
to type replies. I am frequently unable to answer a question until 
much later because of this. Please wait until I have answered before 
asking the next question, or I won't be able to type the answer.
Now in answer to your question, EXTRACT was created by the whole 
REBOL 3 group, though I wrote it. The changes to it were very intentional 
and the result of much debate. Please see the reasoning I wrote above.
[unknown: 5]
23-Mar-2008
[9516]
Well at least I got my skip+ function.
BrianH
23-Mar-2008
[9517]
Under what circumstances are you using out-of-bounds values?
[unknown: 5]
23-Mar-2008
[9518x2]
Does /base include mezzanines?
I don't Brian.  But I might want to know if the series was out of 
range to my request.
BrianH
23-Mar-2008
[9520x2]
I mean out-of-bounds indexes. No, /Base doesn't include most mezzanines 
- you have to load them yourself.
If you need to know id the indexes were out of range, why don't you 
check if the indexes are out of range?
[unknown: 5]
23-Mar-2008
[9522x2]
I don't have to Brian.  Skip+ automatically tells me if they are.
Let's put it this way.  If I was using /base why would I ever use 
EXTRACT over SKIP+?
BrianH
23-Mar-2008
[9524]
That is what I mean. Under what circumstances would the indexes you 
are using ever be out of range, without you checking?
[unknown: 5]
23-Mar-2008
[9525x2]
Yeah if your checking Brian, But EXTRACT doesn't do checking.  SKIP+ 
does.
You have to use additional code to check if your series will be out 
of range if your going to use EXTRACT.  I don't have to with SKIP+.
BrianH
23-Mar-2008
[9527]
I am not asking to be snide, I am asking because we can change EXTRACT 
if the change makes sense.
[unknown: 5]
23-Mar-2008
[9528]
I'm hoping that is your position Brian because if it wasn't then 
REBOL could be in danger of becoming very less appealling.
BrianH
23-Mar-2008
[9529]
It always has been.
[unknown: 5]
23-Mar-2008
[9530x3]
Glad to hear Brian.
SKIP+ is less taxing on the stats/evals also.
SKIP+ wouldn't even exist had I known about extract (my lack of programming 
in REBOL for sometime)
BrianH
23-Mar-2008
[9533]
SKIP+ is a lot more taxing on the stats/evals, actually. There is 
more code in EXTRACT but that code is mostly error checking code 
that is run only once per call. The code that actually does the extract 
is more efficient:

    forskip block width [append/only new any [pick block pos value]]
versus
    series: at series start
    while [not tail? series][

        if (index? series) = start [insert tail blk first series start: start 
        + interval]
        series: next series
    ]
    series: head series
[unknown: 5]
23-Mar-2008
[9534]
That's true but as is the skip+ is more efficient.
BrianH
23-Mar-2008
[9535]
Wait, you may be right. It turns out that forskip is a mezzanine 
in R2, where it is native in R3.
[unknown: 5]
23-Mar-2008
[9536]
Yes that is true which is why I used while.
BrianH
23-Mar-2008
[9537]
That slowdown can be fixed.
[unknown: 5]
23-Mar-2008
[9538]
Even if the slowdown is fixed it will still return [none none none 
none ....] which is a feature of extract I don't particularly find 
as useful as just returning none!