World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Henrik 10-Oct-2011 [4450] | I'm not sure that's the problem here, though. |
todun 10-Oct-2011 [4451] | @Henrik, I see. Is this normal coding or just rebol? |
Pekr 10-Oct-2011 [4452x2] | it is normal rebol :-) |
you might use one trick - result-answer/text: copy " " | |
Henrik 10-Oct-2011 [4454x4] | Try this in the console: repeat i 5 [append [] i] and see what happens. You will see that it literally is that block at that memory location that is reused for APPEND. |
which is a clever way for not needing to assign a word to a block to use it, even just temporarily. | |
so, if you type: in the console, a string is really made. you don't need to assign it. you just have no way to reach it by reference, so it's now left in "oblivion" until the garbage collector picks it up. | |
therefore in this bit of code: button-press?: layout [ ; displays output for user interaction result-question: info " " result-answer: info " " two separate strings are also made prior to the LAYOUT function even getting the block passed. Depending on how the code that manages the INFO faces initializes the face, those two strings can possibly be referenced. | |
todun 10-Oct-2011 [4458x4] | @Henrik, wow! |
@Henrik, so what is REBOL if not call-by-reference? | |
@Pekr, will this work in light of Henrik's remarks? | |
@Pekr, what I mean to say is that will the code be useful in the situation where all of my code seems to be relying on different programming paradigms? | |
Pekr 10-Oct-2011 [4462] | todun - I am not a good programmer, so difficult to say :-) But - many ppl get into some gotchas, when using REBOL. Btw - do you know, that subobjects (objects inside objects) are shared? |
todun 10-Oct-2011 [4463x2] | @Pekr, uhm. do you mean like the scope or something similar? |
@Pekr, I'm actually a new programmer myself. But I didn't start with REBOL thus my confusion. | |
Pekr 10-Oct-2011 [4465x2] | >> person: context [name: copy "" address: context [street: copy ""]] >> a: make person [name: "petr"] >> probe a make object! [ name: "petr" address: make object! [ street: "" ] ] >> b: make person [name: "henrik"] >> a/address/street: "petr's street" == "petr's street" >> probe a make object! [ name: "petr" address: make object! [ street: "petr's street" ] ] >> probe b make object! [ name: "henrik" address: make object! [ street: "petr's street" ] ] |
I mean - when you have a prototype object, which uses subobjects, those are shared between the clones ... | |
todun 10-Oct-2011 [4467] | @Pekr, in this context, what is a prototype object? |
Henrik 10-Oct-2011 [4468] | todun, "call-by-reference" I will defer that question to someone who better knows programming terminology, than me. |
todun 10-Oct-2011 [4469x2] | @Henrik. ok |
thanks all the same. | |
Henrik 10-Oct-2011 [4471] | contexts... also a deep topic. objects in rebol are contexts. there are not really prototypes as any object can act as one. |
todun 10-Oct-2011 [4472] | @Henrik, I still am not sure what prototypes are. So REBOL uses a different structure called a CONTEXT and not an OBJECT? |
Henrik 10-Oct-2011 [4473x2] | try: source context |
Some object oriented programming languages use specially notated prototype objects, from which other objects can be created. REBOL does not. You simply have objects. Prototypes here would be only a concept that you use as a part of your program to discern a "mother" object from other objects. | |
todun 10-Oct-2011 [4475] | @Henrik, so prototypes are nested objects and the fact rebol only deals in objects goes back to its homoiconicity? |
Pekr 10-Oct-2011 [4476] | I think not. The prototype is any object you inherit from ... |
Henrik 10-Oct-2011 [4477] | no, prototypes don't exist at all. |
Pekr 10-Oct-2011 [4478] | Following document might be a bit dated, but it still contains some usefull explanation of REBOL core concepts ... http://www.rebol.com/docs/core23/rebolcore.html |
Henrik 10-Oct-2011 [4479] | it's simpler than one might think: if you have two objects, one made from the other: a: make object! [num: 5] b: make a [num: 7] if you do this without showing this part to another person, that person can't tell which object came first, only that two objects, A and B exist in memory. so there are no real prototypes. |
todun 10-Oct-2011 [4480] | @Pekr, @Henrik, ok. |
Kaj 10-Oct-2011 [4481x4] | Henrik, I have to object. REBOL is prototype based. Any REBOL object/context is a prototype |
Some object oriented programming languages use specially notated prototype objects, from which other objects can be created. | |
Those are not called prototypes; those are called classes | |
Todun, contexts and objects are the same in REBOL. The object word is just used as an alias name because other languages call them that | |
Henrik 11-Oct-2011 [4485x2] | you are probably right, Kaj. |
I had classes and prototypes confused, if I'm not mistaken. So REBOL doesn't have classes. | |
todun 11-Oct-2011 [4487x3] | @Kaj, @Henrik: what do these points mean for design? What I mean is that what conceptual model can I use when thinking about my design of REBOL based applications? |
Going back to my flash cards problem for instance, which I still cannot make work, if I wanted to just apply knowledge on series and VIEW to design this, how can I fix it (pastebin) and/or re-wrie this? I'm really curious to know if there is a design pattern and or way to go about thinking or doing REBOL coding. Thanks. | |
http://pastebin.com/ZEjScLyn | |
Kaj 11-Oct-2011 [4490x3] | If you want to use objects, think in prototypes without inheritance, not classes |
However, before objects, you should be thinking functional programming and data dialects | |
Implementing a design, you'll be doing series manipulations all the time | |
DideC 12-Oct-2011 [4493] | Could you also Pastebin a sample of %temp-cards.txt so we can test the code to see in action what you want it do do ? |
todun 15-Oct-2011 [4494x4] | @Kaj: thanks for the update. |
@DideC: sure thing. I'll pastebin a sample of the temp-cards. | |
http://pastebin.com/w84XhGmE | |
@DideC: thanks. sorry for the late reply. | |
james_nak 15-Oct-2011 [4498] | todun - thanks for posting your code. You know, I never knew there was a "move" function. in R2. |
todun 15-Oct-2011 [4499] | @james_nak: I just found that out here too. |
older newer | first last |