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

World: r3wp

[Core] Discuss core issues

Volker
18-Aug-2005
[1667]
IS there something terrible in it which annois some people, like 
hard religion or something? Else i see none.
Anton
18-Aug-2005
[1668]
ok now it's public.
JaimeVargas
19-Aug-2005
[1669]
How can I read any char from stdin?
Volker
19-Aug-2005
[1670x2]
system/console/input. if you need chars, not lines, set it to binary 
IIRC.
or [lines: false]? something like that.
Anton
19-Aug-2005
[1672]
using SET-MODES I think
Henrik
21-Aug-2005
[1673]
Suggestion: ATTEMPT offers no possibility to provide a default value 
in case of failure. How about:

attempt/failure [2 / 0] "Invalid!"
== "Invalid!"

attempt [2 / 0]
== none

default-values: [a b c]

values: copy attempt/failure [read %values-file] default-values

2% more elegance? Or a debugging trap?
Volker
21-Aug-2005
[1674]
inbuild:
values: copy any[attempt [read %values-file] default-values]
Ladislav has something like your suggestion, called 'default.
Henrik
21-Aug-2005
[1675]
not as clear, but I resorted to this when wanting to read out 0 when 
a numeric computation that is always positive failed:


first maximum-of reduce [0 attempt [2 / 0]] ; what's going on? .... 
oh :-)

attempt/default [2 / 0] 0 ; seems more clear
Volker
21-Aug-2005
[1676x2]
He did not patch attempt, its own. so
 default [ 2 / 0 ] 0  ; IIRC
default [read %values-file] "This file missing"
Henrik
21-Aug-2005
[1678]
found it in RAMBO #3225...
Volker
21-Aug-2005
[1679x3]
one version is here, with explicit error-variable: http://www.fm.vslib.cz/~ladislav/rebol/default.r
- ah, you too.
interesting, i googled for "ladislav default", no "rebol" in it, 
42k hist, this one #4 :)
hist -> hits
Henrik
21-Aug-2005
[1682]
google thinks rambo is a movie character. how quaint!
Volker
21-Aug-2005
[1683x3]
But always in the center of the action?
But why would an actor call himself after a broker?!
ups, no, rambo, not rugby. bug-squasher then.
Henrik
21-Aug-2005
[1686]
Rebol will have sufficient fame when Stallone sues over the RAMBO 
name.
Volker
21-Aug-2005
[1687]
Maybe they join, the next RAMBO is about entering some bad computer 
and sqush all the bugmonsters there?
Robert
21-Aug-2005
[1688]
Does read/skip work in the new releases?
Anton
21-Aug-2005
[1689]
Doesn't look like it. I think file skip was removed because of moving 
to new Windows api.
Pekr
21-Aug-2005
[1690]
When will open/seek be added? It was supposed to be there with new 
async core, we had async core for a while, but I do not remember 
anyone mentioning open/seek is there ...
Anton
21-Aug-2005
[1691x3]
you mean  "file seek"   or  "open/skip".
It was in the experimental releases, like View 1.2.57.3.1
Test with a line like:
	print copy/part read/skip %user.r 10 40    ;   compare 10 with 0
Now, how to add a link without killing the Korean language UTF-8...
Ladislav
21-Aug-2005
[1694x4]
Re DEFAULT. It looks, that a version with implicit variable may be 
more popular:

default: func [
    {Execute code. If error occurs, execute fault.}
    [throw]
    code [block!] {Code to execute}
    fault [block!] {Error handler}
] [
    either error? set/any 'code try code [
        fault: make function! [[throw] error [error!]] fault
		fault code
    ] [get/any 'code]
]
this one uses 'error as the error variable
note: although it looks safe, it may become a victim of the GC bug 
I described in RAMBO group recently. A slower but safer implementation 
is:

default: func [
    {Execute code. If error occurs, execute fault.}
    [throw]
    code [block!] {Code to execute}
    fault [block!] {Error handler}
] [
    either error? set/any 'code try code [
        do make function! [[throw] error [error!]] fault
    ] [get/any 'code]
]
sorry, correction:

default: func [
    {Execute code. If error occurs, execute fault.}
    [throw]
    code [block!] {Code to execute}
    fault [block!] {Error handler}
] [
    either error? set/any 'code try code [
        do make function! [[throw] error [error!]] fault code
    ] [get/any 'code]
]
Volker
21-Aug-2005
[1698]
gc-bug: i prefer the function which overwrites itself cares about 
that, else a lot code will be bloated. caring means plug somewhere 
reachable from global context, like dont-gc-me: :me
Ladislav
21-Aug-2005
[1699x2]
the above code is exactly the case where your suggestion cannot help
moreover, it is more bloated, than the actual solution used
Volker
21-Aug-2005
[1701]
yes, could not get me own function there. but would not reload myself 
by 'default then.
Ladislav
21-Aug-2005
[1702]
sorry, I don't understand the last post?
Volker
21-Aug-2005
[1703]
i would not use default when i know i would trigger the gc-bug.
Ladislav
21-Aug-2005
[1704]
the last version will not trigger it
Volker
21-Aug-2005
[1705x2]
the only time i trap about that bug is when i do a script i did before, 
thus overwriting the loading function.
and in that case i prefer to care mayelf isntead of forcing every 
tool to be aware of it.
Ladislav
21-Aug-2005
[1707]
you don't overwrite the function at all - Rebol functions are anonymous 
in nature, it is just an interpreter bug
Volker
21-Aug-2005
[1708x2]
ok, overwrite the only reference from the global context.
if a safe version is no effort or even shorter, thats ok, will not 
stop that.
Ladislav
21-Aug-2005
[1710]
did you notice why the former version above may become a victim of 
the GC bug while not looking like overwriting the reference?
Volker
21-Aug-2005
[1711x2]
hmm, started re-reading just a moment before. thought maybe i miss 
something.
No, i dont see how. everything is referenced from locals. as long 
as you don't overwrite 'default itself, it should work?
Ladislav
21-Aug-2005
[1713]
actually not, the problem is this:

default [1 / 0] [default [2 / 0] [...] print mold disarm error]
Volker
21-Aug-2005
[1714x2]
but i missed the point anyway, thought 'default takes care if i overwrite 
my own function. to hasty. its because of its own created function 
i guess.
oh, recursion. and locals on the recursion-stack are not checked 
too?
Ladislav
21-Aug-2005
[1716]
aha, it *may* work, I didn't check it