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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
23-Mar-2008
[9677]
ok I remember some discussion about that.
BrianH
23-Mar-2008
[9678]
This is one of those cases where unset! wouldn't be an error, so 
the code handles it.
[unknown: 5]
23-Mar-2008
[9679]
It would be any problem? wouldn't the get/any cause a problem if 
it encountered the unset!?
BrianH
23-Mar-2008
[9680]
That's what the /any is for.
[unknown: 5]
23-Mar-2008
[9681x3]
indeed
don't know that include unset!
don't = didn't
BrianH
23-Mar-2008
[9684x8]
RobertS, have you tried initialization functions?
I think your INITIAL and INITIALLY functions could be combined though.
initially: func [[throw] tag [word!] code [block!] /local tags] [
    tags: []
    unless find tags tag [
        insert tail tags tag
        do code
    ]
]
I suppose a catch attribute would be appropriate to add to the function 
too.
Or you could eliminate the tag:
initially: func [[catch throw] code [block!] /local done] [
    done: []
    unless find done code [
        insert tail done code
        do code
    ]
]
Sorry, not insert, insert/only.
It relies on the FIND finding blocks based on whether they are the 
same, not equal. That means that the reference to the code block 
that is passed to INITIALLY can itself be used as a tag.
Final version:
initially: func [[catch throw] code [block!] /local done] [
    done: []
    unless find done code [
        insert/only tail done code
        do code
    ]
]
[unknown: 5]
23-Mar-2008
[9692]
Rambo 3115 submitted for desire to include the replace-all function.
btiffin
23-Mar-2008
[9693]
RobertS; Regarding initial blocks, make sure you check out http://www.fm.tul.cz/~ladislav/rebol/
and in particular http://www.fm.tul.cz/~ladislav/rebol/#section-5.6
  As Ladislav himself puts it, "a comfortable Func replacement".


An lfunc does all the work of localizing words set in a func, allows 
an init block (of which set-words are wrapped in use for static variables) 
 etc...etc...
BrianH
23-Mar-2008
[9694x2]
Version with reset (that catch attribute is unnecessary):
initially: func [[throw] code [block!] /reset /local done] [
    done: []
    either reset [clear done] [
        unless find done code [
            insert/only tail done code
            do code
        ]
    ]
]
Or you could remove the code block parameter on reset, if you prefer 
to get rid of one block instead of them all.
Graham
24-Mar-2008
[9696x2]
Anyone know why there is a space after the first string?

>> form reduce [ "hello" newline "there" ]
== "hello ^/there"
ie. why isn't it "hello^/there" ?
No matter.
JohanAR
24-Mar-2008
[9698]
I'm more surprised that there isn't a space after the newline, since 
form throws those in everywhere :)
Henrik
24-Mar-2008
[9699x2]
the string may be trimmed, which could be why there's no space after 
the end.
form reduce is the same as reform, btw.
Geomol
24-Mar-2008
[9701]
Might be related to, how PRINT is working, which has a built in reduce. 
This would look weird, if there was a space after the newline:

>> print ["Hello" newline "World!"]
Hello 
World!

And you need those spaces, when doing something like:

>> print ["Hello" "World!"]
Hello World!


So it's because REBOL is clever and do, what you expect. (Mostly.)
Graham
24-Mar-2008
[9702x4]
The space before the newline is annoying ...
Hello <-extra space
World
I can understand spaces between words ... but at the end of a line??
Anyone object to this ?
reform [ "Hello" "world" newline "Again" ] => {Hello word^/Again}
Geomol
24-Mar-2008
[9706x2]
I bet, it's faster, the way it is. The internal rule is:

Add a space after a non-newline.
Don't add after a newline.
May be annoying, but it's fast and small code.
Graham
24-Mar-2008
[9708x2]
I doubt that adding a new rule - don't add a space if next character 
is also whitespace will slow a native down much.
Would it break anything to treat whitespace as special?
[unknown: 5]
24-Mar-2008
[9710x2]
or just rejoin:
>> form rejoin ["hello" newline "there"]
== "hello^/there"
Graham
24-Mar-2008
[9712x2]
rejoin evaluates the contents though which I don't want
I'm only using reform here for clarity .. in reality I use 'form
Geomol
24-Mar-2008
[9714]
It's a very little annoyance, that you can work around. If REBOL 
were close to perfect, it would make sense to go into such things. 
There are much larger problems or things, that's nott finished with 
R3. (My opinion.)
Graham
24-Mar-2008
[9715]
The reason I note this is that I was inserting an EPS into a block 
of words and then forming it.  This adds an extra space on to the 
image data in the EPS and as the routine in the EPS to read the image 
data is white space sensitive, it dies.  I have to do a replace/all 
{ ^/} {^/} on it before I submit to the printer.
[unknown: 5]
24-Mar-2008
[9716x2]
Graham reduce evaluates the contents also.
Rejoin is even built off of reduce.
Oldes
27-Mar-2008
[9718x2]
is there better way how to do this?:
>> trim/all/with form to binary! #"*" "#{}"
== "2A"
or
>> copy/part skip form to binary! #"*" 2 2
== "2A"
maybe:
 skip form to-hex 232 6
Gabriele
27-Mar-2008
[9720]
>> enbase/base "*" 16
== "2A"
btiffin
27-Mar-2008
[9721x3]
Or  first to binary!  42.0.0  ?
Never mind.  :)
Sorry, just found out that to binary! on tuples moves binary and 
not formed binary.  And wanted to try it.  Not what you want in this 
case.
Fork
29-Mar-2008
[9724x3]
Greetings,my name is Brian (http://hostilefork.com).   I am new to 
REBOL, and was introduced here by Reichart.  I have a question I 
can't yet figure out.
In REBOL if I do switch 'x [x [print "hello"]]
I get 
hello