World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
mhinson 30-May-2009 [2891] | Thanks Chris. There are several things I have learnt from this: COPY has more varied use than I was aware of. In this case I think COPY is making sure I am adding a unique empty block, rather than a link to this one. I still cant quite get my head round an empty block being something that can be referenced again later, although I know I have read about it previously & know it is important. Why do I not seem to need COPY in my following example? StructuredData: copy [] thing: copy "toy" append StructuredData reduce[to-word thing[]] owner: copy "child" append StructuredData/(to-word thing) compose/deep [owner[(owner)]] thing: copy "house" append StructuredData reduce[to-word thing[]] owner: copy "adult" append StructuredData/(to-word thing) compose/deep [owner[(owner)]] probe StructuredData [toy [owner ["child"]] house [owner ["adult"]]] |
Graham 30-May-2009 [2892] | You only need to copy if you use it more than once. |
Izkata 30-May-2009 [2893] | It happens because the outer block [to-word thing []] is referencing the inner block |
Chris 30-May-2009 [2894] | mh: In the case above, when you were using 'reduce, you were evaluating the first block, in which the second block is just a value. When you evaluate a block value, it is not in turn evaluated: >> [i'm not code] == [i'm not code] It's important to remember when you do some deeper evaluation: >> code: [[]] ; block containing a block value == [[]] >> append code/1 'a ; modify block value == [a] >> result: do code ; evaluate block, block value returned - now referenced by 'result == [a] >> append code/1 'b ; modify block value == [a b] >> result ; result is referencing the same value == [a b] >> append result 'c == [a b c] >> code == [[a b c]] Every value in REBOL is merely referenced to by the language. Sometimes explicitly: result: [] probe result Or not: code: [[]] probe code/1 Or both: code: [[]] result: code/1 probe same? code/1 result |
mhinson 30-May-2009 [2895] | Thanks Chris, Graham, Izkata I feel like I half get this, but not well enough to be confident yet. I have been trying to create a really simple example where two parts of the same block are really the same items, so changing either, changes both because I think it will help me understand better & that was the behaviour in my original example. Perhaps if I study this for another couple of hours I will get a breakthrough with it. Thanks. |
Chris 30-May-2009 [2896x2] | Such as?: >> attr: [] == [] >> cont: reduce [attr attr] == [[] []] >> insert attr 'c == [] >> insert first cont 'b == [c] >> insert second cont 'a == [b c] >> cont == [[a b c] [a b c]] |
Note that you can continue to reduce the 'cont block, yet the two values remain the same. | |
mhinson 30-May-2009 [2898] | Hi Chris, I am slowly getting there I think. Thanks for additional example. |
Izkata 30-May-2009 [2899] | Try this: Predict the output of these function calls: foo: func [/local A B][ A: [] B: copy [] print mold append A {a} print mold append B {b} ] foo foo foo |
mhinson 31-May-2009 [2900] | ;Thanks Izkata, I predicted the outcome correctly. I went on to try this: D: [{bar}] ;; global D foo1: func [D][D: [] print mold append D {d}] ;; foo2: func [D][D: [] print mold append D {d}] ;; foo1 D ;; value of global D passed to function (but not used) foo1 D ;; function references its own local value of [] to which it keep appending {d} foo2 D ;; same as foo1 but references its own [] ?pointer? thing D ;; still references un changed global D foo1: func [D][D: [] print mold append D {d}] ;; rewriting foo1 foo1 D ;; new foo1 function has new [] pointer foo3: func [][D: [] print mold append D {d}] ;; D is not passed to the function Foo3 ;; now we are changing global D and making it reference foo3 [] pointer D ;; proof global D has changed ;; I think the bit that was making it hard for me to understand was that ;; referencing the same empty block in a function means the actual exact function, ;; a second copy of it even with the same name, sets up a new local pointer. And also the unexpected localness confused me. ;; Question, do my comments show that my understanding is now correct please? |
Izkata 31-May-2009 [2901] | It looks correct to me |
mhinson 31-May-2009 [2902x2] | :-) thanks Izkata.. I may be moving forward at last :-) |
What is the length limit for a comment line please? some of my comment lines are being intrepreted. I think it is the length of them. | |
Graham 31-May-2009 [2904x2] | I'm not aware of any limit. |
Are you doing this? comment { mutliple comments? } | |
mhinson 31-May-2009 [2906] | no, just ;; in front of a few very long lines. |
Graham 31-May-2009 [2907] | well.. as I said, not aware of any limit. maybe it's your editor? |
mhinson 31-May-2009 [2908] | it is like that because I have a bunch of lines that will become a function & I am comparing them in some cases, and excludeing them in other cases to debug my code. |
Graham 31-May-2009 [2909x2] | well, use 'command { } |
comment | |
mhinson 31-May-2009 [2911x2] | ;; ownerRule: ["owner " copy owner to newline ;; ((if (error? try [StructuredData/(to-word thing)/owner]) [append StructuredData/:thing reduce[owner copy[]]])(append StructuredData/(to-word thing)/owner compose/deep [(owner)])) ;; ownerRule: ["owner " copy owner to newline (append StructuredData/(to-word thing) compose/deep [owner [(owner)]])] |
The comment thing sounds good... I will use that instead. Thanks. | |
Graham 31-May-2009 [2913x2] | and you only need a single ; |
;; is redundant | |
mhinson 31-May-2009 [2915] | Those lines I posted still do strange stuff with a single ; at the beginning. Could it be a bug with the console? I do 2 ;; to make them stand out more, although syntax highliting does that already. Thanks. |
Maxim 31-May-2009 [2916] | when using the console, always use: do clipboard:// |
mhinson 31-May-2009 [2917] | Thanks, that avoids the anomolie :-) |
Sunanda 1-Jun-2009 [2918x2] | A tip I picked up off of the Mailing List years ago (thanks to whoever it was) doc: does [do clipboard] then you need to just type doc to DO Clipboard:// |
Opps -- one line of code, and 100% of it is in error:-( doc: does [do clipboard://] | |
Maxim 1-Jun-2009 [2920] | I put this in my %user.r paste: does [do clipboard://] |
Gregg 2-Jun-2009 [2921x2] | I hace CC to write clipboard://, and load-clip and read-clip as well. Very handy. |
I also have CDR for change-dir+to-rebol-file. | |
mhinson 3-Jun-2009 [2923] | Hi, is thre a neater way to do this please an avoid so many reduce statements please? QQ: [] func1: func [o1] [append QQ copy/deep reduce [reduce o1 reduce reduce [reduce o1]]] owner: "Luke" func1 'owner [owner ["Luke"]] |
Chris 3-Jun-2009 [2924x2] | func1: func [o1][append QQ compose/deep [(o1) [(get :o1)]] |
missing close bracket | |
Gregg 3-Jun-2009 [2926] | And sometimes it can make sense to split things up into multiple operations (just food for thought). func1: func [o1] [append QQ o1 repend/only QQ [get :o1]] |
mhinson 4-Jun-2009 [2927] | Thanks everyone. I like the shortcut ideas, once I can find the right %user.r file to modify. I think I probably need to delete all copies & start again as because I have downloaded Rebol several time in my inital confusion when I first started trying to use it my PC is confused. I have not come across GET before so that seems to be my missing link, thanks. |
Sunanda 4-Jun-2009 [2928] | Multiple copies of REBOL is a pain that several of us have. |
Graham 4-Jun-2009 [2929] | It's a result of programming with Rebol which tells us to use 'copy to be safe |
Oldes 4-Jun-2009 [2930x2] | I have no problems with multiple REBOL copies.. I have all REBOL exe files in one directory. The latest version named like rebol.exe, core.exe and older which I sometimes need as rebview1361031.exe for example |
I think I was not doing any REBOL installation.. just DOWNLOAD - COPY - RUN | |
Graham 4-Jun-2009 [2932] | I have .r associated with my editor :) |
mhinson 4-Jun-2009 [2933] | With the shortcut to do clipboard:// it complains if there is no rebol[] header. Do folk only use it for bigger blocks of code, rather than a few lines that need testing? As I suppose pasting it straight into the console for small chunks works pretty well? Thanks. |
Ladislav 4-Jun-2009 [2934] | do read clipboard:// |
mhinson 4-Jun-2009 [2935] | Thanks |
BrianH 4-Jun-2009 [2936] | I often put ;rebol [] in front of my code when testing it, then include the rebol [] when selecting. |
mhinson 5-Jun-2009 [2937] | Hi, I have associated .r files with Rebol/view, but when I open my .r files I get an error ** Access Error: Cabbot open /c/documents ** Near: do/args script system/script/args I tried associating .rs with Rebol/View & that works ok... I suspect this is a windowsy problem, any suggestions please? |
BrianH 5-Jun-2009 [2938] | You need quotes around the association, like this: "%1". Edit the file type in the Folder Options control panel. |
Maxim 5-Jun-2009 [2939] | hope you have XP... cause vista only allows to fix associations thru the registry editor :-( |
BrianH 5-Jun-2009 [2940] | But that's not hard either. |
older newer | first last |