World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
todun 10-Oct-2011 [4470] | 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. |
james_nak 15-Oct-2011 [4500] | Todun, just some of my thoughts. I think you are changing the order of the cards ito indicate the difficulty of a question. When you are saving the %temp-cards.txt, you are at a particular position in your series because of the "qa: next qa" so when you save/all it is saving the series from the current position to the end. If you want to save the whole series, you can add "head qa" which will bring the pointer back to the first item for the save but leave your pointer at the current question. It may help to do some simple tests: >> a: [1 2 3 4 5 6 7 8 9 10] == [1 2 3 4 5 6 7 8 9 10] >> a: next a == [2 3 4 5 6 7 8 9 10] >> save %test.txt a >> read %test.txt == "2 3 4 5 6 7 8 9 10" >> save %test.txt head a >> read %test.txt == "1 2 3 4 5 6 7 8 9 10" move/to a 5 == [6 7 8 9 10] >> save %test.txt head a >> read %test.txt == "1 3 4 5 2 6 7 8 9 10" etc. Also I like to add "probe" as in "probe qa" to different places in my code so I can see what is happening internally as I do stuff. Finally, might I suggest that you actually approach the issue in a different way altogether? You can have a block that has some metadata in it so that a question's difficulty can be assessed by other means such the word "hard" or some number such as 1 = easy and 10 = hard, for example. And allong with that you could keep track of how many times the person missed the question. [ 1 "California" "Sacramento" 1 1 0 1 ] where the block above refers to [ index Question Answer difficulty Attempts Wrong Correct] There's a lot more work to do this but if you can then search for the difficult questions, etc. Your program would control the order of the questions based on some filter such as difficulty, attempts. The user could just mark a question as difficult. Anyway, just a thought. I don't want to make your life hard and I need to go back to my own mess I started. I am in block-o-rama myself. |
Duke 23-Oct-2011 [4501] | Having trouble with the "switch" function. I'm entering the following at the REBOL terminal: >> time: 14:00 == 14:00 >> switch/default time [ [ 8:00 [send [wendy-:-domain-:-com] "Hey, get up!"] [ 12:30 [[cindy-:-dom-:-dom] "Joinme for lunch?"] [ 16:00 [send [group-:-every-:-dom] "Dinner anyone?"] [ ] For my trouble, I get: :) ** Script Error: switch is missing its case argument ** Near: switch/default time [ 8:00 [send [wendy-:-domain-:-com] "Hey, get up!"] 12:30 [[cindy-:-dom-:-dom] "Joinme for lunch?"] ... Am I using the REBOL terminal incorrectly? I'm using rebcore v 2.7.8 |
Henrik 23-Oct-2011 [4502x3] | with the /default refinement, you need one more block, to trigger the default case. |
for multi-line stuff, you can use the built-in very simple editor: >> editor "" write your script and save it and use CTRL-E (I think) to run it. | |
rebcore v 2.7.8 - ok, the editor is not in this version, so you would have to use another editor. | |
Duke 23-Oct-2011 [4505x2] | http://www.rebol.com/r3/docs/functions/switch.html |
Sorry about the previous msg - still getting used to Altme :o I'm taking the examples right from the URL in my previous msg. Is there a simple and bullet-proof way to enter the code at the REBOL console? | |
Henrik 23-Oct-2011 [4507] | You should be able to somewhat safely paste multiline code, but otherwise it's best for single line entry. Also note that the console does not behave identically on different OS'es. |
Ladislav 23-Oct-2011 [4508] | have you tried the do read clipboard:// expression? |
Henrik 23-Oct-2011 [4509] | When developing scripts, I like to use my favourite editor and hook up REBOL to a keyboard shortcut, which is a nice and quick way to study longer REBOL scripts. |
Ladislav 23-Oct-2011 [4510] | Or, if you want to examine what exactly is in the clipboard, you can: print read clipboard:// |
Duke 23-Oct-2011 [4511x3] | @Ladislav nope! but I will ... :) |
Is there an emacs mode for REBOL that you guys are aware of? | |
BTW, I just C&P the code into the console, and BINGO!!! :)) | |
Henrik 23-Oct-2011 [4514] | There should be an emacs mode available. I have never used it, though. |
Duke 23-Oct-2011 [4515] | @Henrik What??? Are you ill? LOL ... |
Henrik 23-Oct-2011 [4516] | I don't use emacs, hence I don't need the REBOL emacs mode. :-) |
Duke 23-Oct-2011 [4517x2] | @Henrik That's my point !! :)) |
Anyway ... thanks you guys!! | |
Izkata 23-Oct-2011 [4519] | @Duke: It works in the console if you put the opening bracket of the final block on the same line as the closing bracket of the previous block, like it is in the example |
older newer | first last |