The first question is whether there are any good books or references
aside from the homepage documentation? I really hate asking questions
on newgroups that I could have found with very little effort on my own.
Likewise, if any of the following questions are readily found on the
main page, my appologies, but there is a lot there to sift through. :-)
I've been trying to get acquainted with Rebol (or is REBOL the proper
way to type it?) for a little while now. As a Common Lisp programmer, I
very much like the similarities. Rebol seems to draw from a lot of
other languages, and that is good. Okay, on to my questions:
This may just be a style/taste issue, but I wonder why Rebol code uses
the [ ] in the same manner that C uses { }. It seems to me much easier
to use them like Lisp ( ), especially since Rebol seems to use [ ] to
denote either lists or code blocks. Consider the following two blocks
of code:
if hex [
either number? value [
value: to-hex value
] [
value: enbase/base form value 16
]
]
vs.
if hex
[ either number? value
[ value: to-hex value ]
[ value: enbase/base form value 16 ]]
To me, the second is by far easier to read. Of course, that could just
be my background as well. The point of the question, though, is I'm
wondering if I've missed something fundamental in the Rebol code syntax
which makes the former better (eg, the second could be mistaken for
something else).
Okay, next question: I'm having a bit of trouble dicerning when to use
symbol: vs. set 'symbol. I can tell no difference, myself, between
them, but one must exist. Also, I wonder why the following code works,
and the latter doesn't:
view layout
[ foo: button "test" [ foo/text: "it works!" ]]
view layout
[ foo: button "test" [ set 'foo/text "nope :("]]
Next: it appears as though Rebol (because of the Haskell-ish/functional
programming style) doesn't have operator precedence? I missed this in
any documention, and just wanted to make sure this was the case. 2 + 4
* 5 == 30 and not 22, right?
Tivial question: when I switch to the console from Rebol/view, is it
possible to go back through a command or something? I end up having to
close the console and relaunch the view right now. :-(
Related to the previous question: is there a way to launch a program
"safely" from the view? Sometimes (well, often right now while I'm
learning), if I have a big enough bug in my code, the whole view will
close after reporting the error in the console.
Is it possible to set data permanently using code? Hmm, that doesn't
seem to make much sense. Heh, ok, asked a different way... Using the
demo program HyperNotes (God, I love that little app), I'd like to be
able to mark date and time that I made last editted the page. So, in
the page's source I do something like:
\VID
label to-string now/time
/VID
However, this updates whenever the page is redisplayed, and not just
after an edit. I wouldn't expect the above to to so, but I wonder how
(perhaps) I could store the date in a variable and then have it update
only when saved out again, vs. every time the Rebol interpreter gets to
it.
Is there a way of creating user-defined types or classes? I'm sure
there is, but I have yet to come across it in any documentation.
Last, is there just a general Rebol runtime or interpreter that can run
arbitrary code files or do I need to launch the view every time I want
to run my test apps? I assume this is through a licensed version, but I
thought I'd make sure. And the end of the day, what's the easiest/best
way to distribute a Rebol application? And can they be compiled (to
either bytecode or native format)?
Probably very simple questions, but they've been lingering. If the
group is active, then, to whomever takes the time, thanks for the
answers. :-)
Jeff M.
On 2/26/06, Jeff M. <mas...@gmail.com> wrote:
>
> I don't know how active this group is, but I thought I would pop on and
> say "hello" - and ask a few questions.
>
> The first question is whether there are any good books or references
> aside from the homepage documentation? I really hate asking questions
> on newgroups that I could have found with very little effort on my own.
> Likewise, if any of the following questions are readily found on the
> main page, my appologies, but there is a lot there to sift through. :-)
>
Pretty scattered, books are old, other infos everywhere.
Asking others on ml or altme is quite usual.
Lately, http://musiclessonz.com/rebol_tutorial.html seems to be quite good.
> I've been trying to get acquainted with Rebol (or is REBOL the proper
> way to type it?) for a little while now. As a Common Lisp programmer, I
> very much like the similarities. Rebol seems to draw from a lot of
> other languages, and that is good. Okay, on to my questions:
>
> This may just be a style/taste issue, but I wonder why Rebol code uses
> the [ ] in the same manner that C uses { }. It seems to me much easier
> to use them like Lisp ( ), especially since Rebol seems to use [ ] to
> denote either lists or code blocks. Consider the following two blocks
> of code:
>
> if hex [
> either number? value [
> value: to-hex value
> ] [
> value: enbase/base form value 16
> ]
> ]
>
> vs.
>
> if hex
> [ either number? value
> [ value: to-hex value ]
> [ value: enbase/base form value 16 ]]
>
> To me, the second is by far easier to read. Of course, that could just
> be my background as well. The point of the question, though, is I'm
> wondering if I've missed something fundamental in the Rebol code syntax
> which makes the former better (eg, the second could be mistaken for
> something else).
Nothing big, mostly preference of Carl AFAIK.
One reason is, multiple codelines can be pasted in the console.
Because of the "[" at end console knows more lines follow.
In lisp you have a paren first, no problem there.
>
> Okay, next question: I'm having a bit of trouble dicerning when to use
> symbol: vs. set 'symbol. I can tell no difference, myself, between
> them, but one must exist. Also, I wonder why the following code works,
> and the latter doesn't:
>
One is, they look different.
That is important in dialects.
For example, if you make an object, it searches for "symbol:" and
makes these members.
It ignores 'symbol, so these stay global.
ctx: context[
member: "thats me"
set 'global "i am outside"
]
?? ctx ?? global
The usual rebol-way for namespaces and exporting.
A technical difference is, with set you can you can have indirection.
word-with-symbol: 'symbol ; or "set 'word-with-symbol"
set word-with-symbol 24
Now symbol is changed, not word-with-symbol (that little "'" makes the
difference).
> view layout
> [ foo: button "test" [ foo/text: "it works!" ]]
>
> view layout
> [ foo: button "test" [ set 'foo/text "nope :("]]
>
For some mysterious reason set works with words, but not pathes.
You could still use: set in foo 'text "should work"
> Next: it appears as though Rebol (because of the Haskell-ish/functional
> programming style) doesn't have operator precedence? I missed this in
> any documention, and just wanted to make sure this was the case. 2 + 4
> * 5 == 30 and not 22, right?
>
Yes. Nowhere in documentation? Uhm, thats bad..
> Tivial question: when I switch to the console from Rebol/view, is it
> possible to go back through a command or something? I end up having to
> close the console and relaunch the view right now. :-(
type: desktop
>
> Related to the previous question: is there a way to launch a program
> "safely" from the view? Sometimes (well, often right now while I'm
> learning), if I have a big enough bug in my code, the whole view will
> close after reporting the error in the console.
>
I dont understand what you want.
It should keep the console open for examination,
read message, fix bug, rerun script?
Or not getting console open, but catch error?
Easiest is
if not attempt[ all my code 'ok][alert "Had error, bye"]
But then you see no error-msg while debugging
Or, view-windows are death when the console is active.
if you want to continue, that is: do-events
> Is it possible to set data permanently using code? Hmm, that doesn't
> seem to make much sense. Heh, ok, asked a different way... Using the
> demo program HyperNotes (God, I love that little app), I'd like to be
> able to mark date and time that I made last editted the page. So, in
> the page's source I do something like:
>
> \VID
> label to-string now/time
> /VID
>
> However, this updates whenever the page is redisplayed, and not just
> after an edit. I wouldn't expect the above to to so, but I wonder how
> (perhaps) I could store the date in a variable and then have it update
> only when saved out again, vs. every time the Rebol interpreter gets to
> it.
That works similar to html and javascript. Builds the display on demand.
Your wish would need some extension in Hypernotes, to store data in
the document.
I guess coding would be easy, but a good interface hard. Maybe:
\DATA
my-time: to-string now/time
/DATA
\VID
label my-time
/VID
How about initialisation of newly added fields etc.
>
> Is there a way of creating user-defined types or classes? I'm sure
> there is, but I have yet to come across it in any documentation.
>
object1: make object![member: 1]
object2: make object1[member2: 2]
Prototype-oo.
> Last, is there just a general Rebol runtime or interpreter that can run
> arbitrary code files or do I need to launch the view every time I want
> to run my test apps? I assume this is through a licensed version, but I
> thought I'd make sure. And the end of the day, what's the easiest/best
> way to distribute a Rebol application? And can they be compiled (to
> either bytecode or native format)?
>
run view.exe from os-shell with a script-name.
By default /view associates *.r with itself IIRC,
then you can just click on source-files from explorer.
> Probably very simple questions, but they've been lingering. If the
> group is active, then, to whomever takes the time, thanks for the
> answers. :-)
Not active, but some people stayed subscribed.
Pointed to the other meeting-places in
http://groups.google.com/group/Rebol/browse_thread/thread/9f4395f518122516
HTH :)
>
> Jeff M.
>
>
>
>
--
-Volker
"Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem." David
Wheeler
On 2/26/06, Jeff M. wrote:
> I thought I would pop on and say "hello" - and ask a few questions.
I think you'll be impressed by the level of help and general
enthusiasm from the members of this list. I don't normally answer many
questions, but I'll take a shot at it.
> The first question is whether there are any good books or references aside from the homepage documentation?
There have been several books published, although I'm not sure they
are currently in print. Nonetheless, you should be able to find one or
more on the second hand market. Here are the titles (from memory--
note: they could be slightly different):
The Official Guide - Elan Goldman and Mark Blanton
REBOL for Dummies - Ralph Roberts
REBOL/View (in French) - Olivier Auverlot
You can find some 3rd party tutorials listed on the rebol.net site:
http://www.rebol.net/article/0201.html
> This may just be a style/taste issue, but I wonder why Rebol code uses the [ ] in the same manner that C uses { }.
Style is considered very important in Rebol. Carl Sassenrath has
written about it on several occasions, more recently here:
http://www.rebol.net/article/0102.html
> Okay, next question: I'm having a bit of trouble dicerning when to use symbol: vs. set 'symbol.
Rebol is highly dynamic and provides multiple ways of accomplishing
basic things. I believe the idea is to enable you to manipulate Rebol
in Rebol.
> Also, I wonder why the following code works,
> and the latter doesn't:
>
> view layout
> [foo: button "test" [foo/text: "it works!"]]
>
> view layout
> [foo: button "test" [set 'foo/text "nope :("]]
In both expressions, foo/text is a path value which evaluates to the
word text in object foo. A couple of points which may highlight the
error: 1 - the function set expects a word value, not a path value,
and 2 - the value you want to set is 'text, but you've misapplied the
symbol notation to the object.
Path values are a bit tricky, so you should read up on them in the
User Guide. I don't it's possible to mix a symbol/literal value within
the path notation, but I'm no REBOL guru and someone may step in and
correct me.
> 2 + 4 * 5 == 30 and not 22, right?
Correct. The REBOL User's Guide covers this, I think.
http://www.rebol.com/docs/core23/rebolcore.html
> Tivial question: when I switch to the console from Rebol/view, is it possible to go back through a command or something? I end up having to close the console and relaunch the view right now. :-(
From the console, the command desktop will launch the /view desktop.
> if I have a big enough bug in my code, the whole view will
> close after reporting the error in the console.
Not sure if I understand completely. For /view errors, on Windows, if
a script errors-out, I usually go over to the console and use the
unview function to eliminate the frozen /view GUI. unview/all will
close all displayed /view GUIs. Examine the unview function for more
options, such as unviewing individual windows.
> I'd like to be able to mark date and time that I made last editted the page. So, in the page's source I do something like:
Hopefully someone with Hypernotes familiarity will help you with this
specific question.
> Is there a way of creating user-defined types or classes? I'm sure there is, but I have yet to come across it in any documentation.
I don't believe user-defined types are supported, although some clever
hacks may be known. Objects are probably the closest thing.
> Last, is there just a general Rebol runtime or interpreter that can run arbitrary code files or do I need to launch the view every time I want to run my test apps?
Pretty sure you need to launch the view version of the interpreter every time.
> And the end of the day, what's the easiest/best
> way to distribute a Rebol application? And can they be compiled (to either bytecode or native format)?
The best way is to make your scripts available in the REBOL.org script
library! Well, I suppose you're talking about package/distribution
with some level of source protection. SDK is what you want. Not that
well documented, but once you figure it out, it's definitely great.
Best regards, and enjoy REBOL. It's different, but really handy.
Ed
JM> The first question is whether there are any good books or references
JM> aside from the homepage documentation? I really hate asking questions
JM> on newgroups that I could have found with very little effort on my own.
JM> Likewise, if any of the following questions are readily found on the
JM> main page, my appologies, but there is a lot there to sift through. :-)
Don't be afraid to ask. People asking questions (on the ML in
particular) is what keeps the community active. There are a number of
REBOL AltME worlds now, which is why the ML and this group are used
much less these days. I can set you up an account on the main one if
you want; just email me and let me know (username preference and
email).
JM> This may just be a style/taste issue, but I wonder why Rebol code uses
JM> the [ ] in the same manner that C uses { }. It seems to me much easier
JM> to use them like Lisp ( ), especially since Rebol seems to use [ ] to
JM> denote either lists or code blocks. Consider the following two blocks
JM> of code:
In REBOL, everything is a block, though that's not obvious at first.
There is no code, just blocks of data that are evaluated. It's a style
thing, to be sure. I like REBOL's style standard; never really got
into Lisp, and some of that was style related (I liked Logo better in
that regard). Also, REBOL is not purely functional, so it walks a line
in style from a Lisp or Haskell view.
Your example could be done a few ways in REBOLish style:
(this is all untested code)
if hex [
value: either number? value [to-hex value] [enbase/base form value 16]
]
if hex [
value: either number? value [to-hex value] [
enbase/base form value 16
]
]
This one being closer to what you prefer:
if hex [
value: either number? value
[to-hex value]
[enbase/base form value 16]
]
or even this way:
value: all [
hex
any [
all [number? value to-hex value]
enbase/base form value 16
]
]
REBOL is felixble, write to communicate.
One of the big things to keep in mind is that REBOL's evaluation is
free ranging--you don't have those parens to tell when something
ends, like in Lisp.
JM> Okay, next question: I'm having a bit of trouble dicerning when to use
JM> symbol: vs. set 'symbol. I can tell no difference, myself, between
JM> them, but one must exist.
Volker hit this one as far as setting the word in the global context.
You'll probably use the set-word! syntax most of the time, and SET
when you need to set a value indirectly, or want to export a word from
a context.
JM> Related to the previous question: is there a way to launch a program
JM> "safely" from the view? Sometimes (well, often right now while I'm
JM> learning), if I have a big enough bug in my code, the whole view will
JM> close after reporting the error in the console.
Normally the console won't close (unless you issue a quit of course).
Have you tried LAUNCH? I think that's available in all versions now
JM> However, this updates whenever the page is redisplayed, and not just
JM> after an edit. I wouldn't expect the above to to so, but I wonder how
JM> (perhaps) I could store the date in a variable and then have it update
JM> only when saved out again, vs. every time the Rebol interpreter gets to
JM> it.
Not entirely sure I follow, but an external data/config file seems
like the solution to me.
JM> Is there a way of creating user-defined types or classes? I'm sure
JM> there is, but I have yet to come across it in any documentation.
REBOL is prototype based, like Self. Things to be play with are how to
MAKE (see also: CONSTRUCT) and copy objects. There are no private
members in REBOL objects, though you can get fancy later if you need
that kind of thing. Because every object is "unique", functions in an
object go with the object and can be customized in each one. The flip
side is that objects are heavier the more functions you put in them,
so there are times where functions are broken out, and referenced, to
keep objects lighter.
HTH!
--Gregg