World: r3wp
[Core] Discuss core issues
older newer | first last |
Graham 6-Jul-2010 [17252] | >> o: construct [ a: true b: yes c: on ] >> probe o make object! [ a: true b: 'yes c: true ] |
Maxim 6-Jul-2010 [17253] | replied there... I usually mold/all for such things... o: construct [ a: true b: yes c: on ] >> print mold/all o #[object! [ a: #[true] b: yes c: #[true] ]] |
Graham 6-Jul-2010 [17254] | construct should not evaluate .. but it is |
Maxim 6-Jul-2010 [17255x2] | true values are a specific special case... they are not evaluated. |
construct exiplictely looks for the words none, true, false, yes, no and replaces them with their value equivalents. | |
Graham 6-Jul-2010 [17257] | So, why is yes not evaluated but true and and on are? |
Maxim 6-Jul-2010 [17258x2] | sorry... that would be on, off (not yes no) |
probably because Carl forgot to include yes/no into the construct special case... its possible he did it on purpose. | |
Graham 6-Jul-2010 [17260] | No, it's a bug |
Maxim 6-Jul-2010 [17261] | note, they are not evaluated, even if you replace them with functions which have the same word. |
Graham 6-Jul-2010 [17262x3] | works correctly in R3 but not in R2 |
this is r3 >> a: construct [ a: true b: on c: yes ] == make object! [ a: true b: true c: true ] | |
Where are r2 bugs posted these days?? | |
Maxim 6-Jul-2010 [17265] | still rambo. |
Graham 6-Jul-2010 [17266] | Just downloaded 2.7.7 to be sure that the bug is still there and it is |
Endo 6-Jul-2010 [17267] | yep, it is still there, I use 2.7.7. I use this function to test: f: func ['w] [type? get in construct compose [t: (:w)] 't] >> f yes == word! >> f off == logic! forum topic is "Careful when Construct an object" on http://rebolforum.com, above link goes another topic. (a bug on forum, topic numbers changing) |
Graham 6-Jul-2010 [17268] | I posted the bug report |
Vladimir 6-Jul-2010 [17269] | Thanks Gregg!!! It works just the way I need it to work :) |
BrianH 6-Jul-2010 [17270x5] | The yes and no keywords of R3's CONSTRUCT were added at my request. We'll have to see whether the enhanced function can be backported to R2 safely. There are other changes as well, mostly safety changes, and a CONSTRUCT/only option that turns all of the tricks off. |
Bug#651 details the changes - yes and no keywords, and unset-to-none translation - and bug#687 explains CONSTRUCT/only. | |
We'll have to see if there is any R2 code that will be broken by the change; if so, it won't happen. As a rule, backwards-incompatible changes are only made to R2 when they can be proven to not harm legacy code. There have been a few exceptions, and at least one mistake that predated (and inspired) the rule, but the exceptions have all been added functionality that doesn't change old functionality that is relied on in code. If nothing relies on yes and no not being keywords, or unset! values not being translated to none, then we're cool. As a counter-example, CONSTRUCT/only could be backported without question because it's a new option. | |
One caveat to new options: Once APPLY is backported (planned for 2.7.8) then new options will need to be added to the end of the options list of functions, not in the middle. APPLY is positional when it comes to options. | |
This is already a concern for those using the R2/Forward backport of APPLY. | |
Pekr 8-Jul-2010 [17275x2] | What is the easiest way to prevent sub-object sharing? I have very simple but nested XML structure, and I want to put records into objects. But I have one subobject. I want to have prototype object (class) and create instances filled with data, but I want to avoid subobject sharing .... |
simply put: proto: context [name: none address: context [street: none]], and now I want to make instances, but those should not share address subobject ... | |
Anton 8-Jul-2010 [17277] | You're going to have to clone the subobjects, eg. instance1: make proto [ address: make address [] ; Clone object to avoid sharing. ] |
Ladislav 8-Jul-2010 [17278] | Just define your own constructor, that is all |
Pekr 8-Jul-2010 [17279] | Ah, thank you very much ... I thought I could somehow avoid that, but that's ok .... |
Maxim 8-Jul-2010 [17280x2] | I put an init function in the class, and do any stuff there, then its much easier to manage. a: make class [init] |
you can also make a function which call init , if its there. new: func[class spec /local obj][obj: make class spec if function? get in obj 'init [obj/init]] | |
Steeve 8-Jul-2010 [17282] | if you keep the prototype as a block you don't need to do so >> context proto |
Ladislav 8-Jul-2010 [17283] | Nevertheless, the "use your own constructor" variant is the only "truly object-oriented" one |
Maxim 8-Jul-2010 [17284] | yes, my above one-line constructor func scales very well, since you can call new on sub-objects too, and it will take care of any things like creating empty new blocks and formatted strings on the fly, within the init func. |
Ladislav 8-Jul-2010 [17285x2] | My suggestion would be more like: my-class: make object! [ new: func [...] [...] ] my-class-instance: my-class/new ... |
, but, you can use whatever suits your needs | |
Maxim 8-Jul-2010 [17287] | yes, the power of rebol to define our own models :-) |
Henrik 10-Jul-2010 [17288] | How is it again that one decodes a url? Sometimes I forget the simple things. |
Graham 10-Jul-2010 [17289] | dehex ? |
Henrik 10-Jul-2010 [17290] | thanks |
amacleod 10-Jul-2010 [17291] | Is there something like "unmold"? I find myself needing to return a molded block back to a block all the time. |
Henrik 10-Jul-2010 [17292] | load |
amacleod 10-Jul-2010 [17293] | dope |
Henrik 10-Jul-2010 [17294] | remember to MOLD/ALL if you don't want to lose information. |
Demitri 10-Jul-2010 [17295] | I have r2 question. I wont to convert integer value to binary but it comes out wrong. Some tell me how? The integer is above 255. |
Graham 10-Jul-2010 [17296] | Tell us what you are doing |
Demitri 10-Jul-2010 [17297] | I trying to convert integer value to binary. |
Izkata 10-Jul-2010 [17298] | >> debase/base to-hex 512 16 == #{00000200} |
Demitri 10-Jul-2010 [17299] | thx you Izkata. |
Anton 10-Jul-2010 [17300] | Dope doesn't work that well. |
Ladislav 14-Jul-2010 [17301] | I think, that everybody processing REBOL strings using REBOL shall be aware of CureCode #1632. I should probably write an article about the subject somewhere to make life of at least some people easier. |
older newer | first last |