World: r3wp
[Core] Discuss core issues
older newer | first last |
Rebolek 15-Jul-2005 [1532x4] | I've got a question. I don't know how to describe it, so here is the code |
>> a: context [b: 1 c: does [b: b + 1]] >> f: func [fn][loop 100 [fn]] >> a/c == 2 >> f a/c == 3 >> f get in a 'c == 103 | |
Why there's difference between f a/c and f get in a 'c | |
I think they should behave same, shouldn't they? | |
Allen 15-Jul-2005 [1536x2] | I don't see why they should be the same. One is using path evaluation to execute c, the other is asking for the value of c. |
> type? get in a 'c == function! | |
Rebolek 15-Jul-2005 [1538] | OK thanks, I'll do it another way |
Gabriele 15-Jul-2005 [1539] | volker: i think that rule always applies if you want to be safe. you never know what someone could be doing to work around your safety; more checks means safer. |
[unknown: 5] 17-Jul-2005 [1540] | anyone know what the 'run function does? I always get a message that its not available in this version of rebol but I am using sdk so not sure why. |
Sunanda 17-Jul-2005 [1541x2] | In Command: >> help run USAGE: RUN file /as suffix DESCRIPTION: Runs the system application associated with a file. RUN is a native value. ARGUMENTS: file -- The file to open (file, URL) or command to run (string). (Type: file url string) REFINEMENTS: /as suffix -- (Type: string file) |
Though having just tried it......it didn't work either. Looks like an older name for call | |
Graham 17-Jul-2005 [1543x2] | it's not. |
run will call a native application to open the file in question eg. acrobat reader for pdf files. It is only enabled on IOS .. I have asked RT why it can't be enabled for the sdk as well. | |
[unknown: 5] 18-Jul-2005 [1545] | Yes Graham that is what it looks like to me as well - looks similiar to a winshellexecute function. Would be good for them to activate it as that would be a very good function to have. |
Carl 19-Jul-2005 [1546] | And, perhaps even REBOL View too eh? |
[unknown: 5] 19-Jul-2005 [1547] | Ahhh not complaint here Carl. |
Rebolek 21-Jul-2005 [1548x2] | Is this OK? And if yes, then why? |
>> x: context [d: does [print e]] >> y: make x [e: 1] >> y/e == 1 >> y/d ** Script Error: e has no value ** Where: d ** Near: print e | |
Cyphre 21-Jul-2005 [1550] | yes, this is OK |
Rebolek 21-Jul-2005 [1551] | and why? |
Cyphre 21-Jul-2005 [1552x2] | because you refer to word 'e with global context |
>> x: context [d: does [print self/e]] >> y: make x [e: 1] >> y/d 1 | |
Rebolek 21-Jul-2005 [1554] | ok I see |
Cyphre 21-Jul-2005 [1555x2] | In this case it would work: >> x: context [e: 5 d: does [print e]] >> y: make x [e: 1] >> y/d 1 |
because the 'e in function d would be bound to the context of the object (self) | |
Rebolek 21-Jul-2005 [1557x2] | yes I know, I needed it when extending objects |
so I'll use 'self or define everything in advance | |
Cyphre 21-Jul-2005 [1559] | If you use 'self you are safe rearding contexts IMO. |
Ladislav 21-Jul-2005 [1560x2] | if you want to extend context, you might want to try associative array instead |
or a "dynamic" object like o: make object! [data: make object! [x: 1]] usage: >> o/data/x == 1 >> o/data: make o/data [y: 5] >> o/data/x == 1 >> o/data/y == 5 | |
Joe 23-Jul-2005 [1562] | . |
Ingo 25-Jul-2005 [1563x4] | Q1: I want to replace all 'none in a block with _different_ empty strings, what's the fastest way to do this? (replace/all BLOCK none "" replaces all 'none with the same empty string) |
Q2: I have to blocks containing strings, and want to find out which of these strings differ (I need all differing positions), what do you think is the fastest way to achieve this? | |
Thanks in advance for all ideas! | |
PS. Do you, like me, feel that the replace way of doing things is questionable? | |
Volker 25-Jul-2005 [1567] | b: ["s1" "s2" "s3" "s1"] parse b[any[to "s1" p: (p/1: copy "t0") skip]] ? b |
Ingo 25-Jul-2005 [1568] | Q2 again: Sorry, my axplanaition was a little unclear: I have a row from a database, and store away one block, and display the other for the user. The user may, or may not, change the data. >> orig: ["Mr" "Petr" "Ustinov"] >> data: ["Sir" "Peter" "Ustinov"] >> magic-changed-func orig data == [1 2] |
Volker 25-Jul-2005 [1569] | orig: ["Mr" "Petr" "Ustinov"] data: ["Sir" "Peter" "Ustinov"] ; same length ! out: copy[] repeat i length? orig [ if orig/:i <> data/:i [ append out i ] ] ? out |
BrianH 25-Jul-2005 [1570x3] | Q1:use [x] [ |
Sorry | |
Q1: use [x] [ x: block while [x: find x none!] [change x copy ""] ] | |
Anton 26-Jul-2005 [1573x2] | Ingo, I have similar feelings too sometimes. I need a higher level function to do some things like that, but it's not there.... |
I often wanted reduce and compose to not make a copy for you, but work directly on the block. (Perhaps new functions "induce" and "impose" ?) | |
Sunanda 26-Jul-2005 [1575] | induce should be fairly easy -- walk the block with 'for and 'poke back the value |
Anton 26-Jul-2005 [1576x3] | blk: [a b c] format: [(1 + 2) (random 100) c] impose: func [blk format][repeat n length? format [if paren? format/:n [poke blk n do format/:n]]] impose blk format ;blk == [3 95 c] |
For induce I think I would use do/next. | |
induce: func [blk format][change blk reduce format] ; (except, as a native!, without creating a temporary block) induce blk [1 + 2 random 100 'c] ; == [3 67 c] | |
Ingo 26-Jul-2005 [1579x2] | Hi Voker, BrianH, thanks for your ideas ... they look mighty long compared to normal Rebol code ;-) |
Sorry, I wanted to type Volker, of course! | |
Brett 26-Jul-2005 [1581] | ; Q1: copy/deep will give you new strings: block: [none none none] new-block: copy/deep replace/all block 'none {} |
older newer | first last |