World: r3wp
[Core] Discuss core issues
older newer | first last |
Rebolek 8-Aug-2005 [1632] | Have to go now, I'll try it at home and let you know. |
Volker 8-Aug-2005 [1633] | Bye Kru, hpe it works. |
Rebolek 8-Aug-2005 [1634x2] | Thanks |
volker thanks, now it does exactly what I wanted and I can expand functions | |
[unknown: 10] 8-Aug-2005 [1636x2] | Has anyone seen an Language overview regarding Performance on funtions etc... that includes Rebol ?? |
somekind of comparisment chart... | |
Ladislav 8-Aug-2005 [1638] | Bolek, your first example would have worked too, if you did: append second :a compose [b (second second :a)] |
Rebolek 8-Aug-2005 [1639x3] | Ladislav nice solution! |
Or, more generally: append second :a compose [b (first find second :a 'value)] | |
Interesting | |
Chris 9-Aug-2005 [1642] | ; Similar, but you can ensure the position of a word to bind to -- b: func [value][print ["value:" value]] a: func [value][[value] probe value] append second :a bind [b value] first first second :a |
Rebolek 9-Aug-2005 [1643] | This is good with one variable, but what if I've got more variables? (e.g. three like in [face action event]) |
Ladislav 9-Aug-2005 [1644x3] | that is even easier. You justg |
...you just need one properly bound variable and you can bind all other code using | |
...it | |
Rebolek 9-Aug-2005 [1647x2] | the problem is I don't know the name of variable so I was trying to get the new from function arguments, but I did not succeed |
...get the name | |
Chris 9-Aug-2005 [1649x4] | That makes it difficult -- to bind one context to another, you need that word from the target context. And functions don't have a 'self value like objects. Nor are 'first and 'third values bound to the 'second. |
You could loop through the args (first) to find an appropriate word in the body (second), but you rely on and argument word being present in the function body -- does that make sense? | |
rely on and == rely on an | |
eg. I don't think it'd be possible to bind any block to -- a: func [x y][] | |
Benjamin 15-Aug-2005 [1653] | how can i know how many data is beeing uploaded to a site when using write ftp://........we have the read-net or read-thru to know how many data is beeing downloaded but what about writing ??? |
Geomol 16-Aug-2005 [1654x9] | The UNIX cd command (a one-liner) in REBOL: |
cd: func ['dir [file! word!] ][change-dir dirize to-file dir] Now it's possible to type e.g.: cd .. cd rebol/view etc. | |
Oops! cd rebol/view is not possible. :-) | |
cd: func ['dir [file! word! path!] ][change-dir dirize to-file dir] NOW it's possible. | |
Question to myself: Why didn't I just write: cd: func ['dir][change-dir dirize to-file dir] There are many ways to write almost the same thing in REBOL with differenct side-effects. Good or bad!? I'm not sure, but it's fun! :-) | |
Another version, that will get to back to system/options/path, if 'cd' has no argument: cd: func ['dir [any-type!][either value? 'dir [change-dir dirize to-file dir][change-dir system/options/path]] | |
get to = "get you" | |
I put REBOL versions of many often used UNIX commands in a "unix.r" script, that I put in my rebol/view directory, so I can easily get to them, when I have to use the REBOL prompt. Just an idea for others. | |
An easy one: pwd: :what-dir | |
Anton 17-Aug-2005 [1663] | There's also the group "*nix-sh" for discussing this. |
Geomol 17-Aug-2005 [1664] | Thanks! |
Graham 18-Aug-2005 [1665] | *nix-sh is a private group ... |
Anton 18-Aug-2005 [1666] | Any reason why I shouldn't make it public ? |
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 | |
older newer | first last |