Hi Gerard,
I once use this little trick for handling a variable number of argument:
f: func [a [integer!] b [unset! integer!]][either value? 'b [a + b][a]]
f 1 2
== 3
f 1
== 1
Please remark that the type of the argument must be explicitely declared, otherwise:
f: func [a b][either value?
[EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 8:12 AM
Subject: [REBOL] Re: [Function] with [Variable number of args]
Hi Gerard,
I once use this little trick for handling a variable number of argument:
f: func [a [integer!] b [unset! integer!]][either value? 'b [a + b
On Tue, 6 Apr 2004 08:12:01 +0200, Coussement Christophe
[EMAIL PROTECTED] wrote:
I once use this little trick for handling a variable number of argument:
f: func [a [integer!] b [unset! integer!]][either value? 'b [a + b][a]]
Hi, clever! This is a very cool trick... I hope I remember it.
On Dienstag, 6. April 2004 11:13, Robert M. Münch wrote:
On Tue, 6 Apr 2004 08:12:01 +0200, Coussement Christophe
[EMAIL PROTECTED] wrote:
I once use this little trick for handling a variable number of argument:
f: func [a [integer!] b [unset! integer!]][either value? 'b [a + b][a]]
Of course, one has to be careful that the result of the
expression following this magical function does not
get eaten up by mistake. In this case, you should wrap
in parens. Example (imagine in a script):
(f 1)
; now let's do some real work
; lots of comments...
Thanks to you all,
Christophe, Cyphre, Volker, Anton and indirectly others too for your comments and
vision about how to effectively use REBOL for
solving the daily challenges we all have as programmers ...
Your solutions will be studied diligently since they also showed me other interesting
Hi Gerard,
Two ways of passing a variable number of arguments [that I know of] are
blocks and refinements. Block usage:
f: func [v [integer! block!]][...]
f 1
f [1 2]
or refinements:
f: func [v1 [integer!] /var v2 [integer!]][...]
f 1
f/var 1
Hi Ashley and Maxim,
From Ashley:
=
Two ways of passing a variable number of arguments [that I know of] are
blocks and refinements. Block usage:
f: func [v [integer! block!]][...]
f 1
f [1 2]
or refinements:
f: func [v1 [integer!] /var v2 [integer!]][...]
f 1
f/var 1 2
I have already seen somebody here redefine the REBOL PRINT
for use its own PRINT substitute with extensions instead and
when leaving
his own context put back the normal PRINT so everything seems
normal after.
slim includes (as part of its basic toolset) a very advanced print mechanism,
Hi Tim,
On Monday, March 22, 2004, 7:51:08 PM, you wrote:
function? 'forall
TJ == false
function? :forall
== true
type? 'forall
== word!
function? get 'forall
== true
Regards,
Gabriele.
--
Gabriele Santilli [EMAIL PROTECTED] -- REBOL Programmer
Amiga Group Italia sez. L'Aquila ---
I'll add that
a word of the form :word is a get-word! datatype.
and using your (and my) example, the following form also works if you are in the
global namespace (like when you're in the console)
function? get 'forall
get returns value of the word instead of evaluating it.
-MAx
function? :forall
you must supply a function VALUE for function to return true. if you don't prepend
the function name by a colon, then the function is -obviously- evaluated.
function? get in system/words 'forall
is another way to do it... it even lets you find functions in objects.
-MAx
* Maxim Olivier-Adlhoch [EMAIL PROTECTED] [040322 10:41]:
I'll add that
a word of the form :word is a get-word! datatype.
and using your (and my) example, the following form also works if you
are in the global namespace (like when you're in the console)
Thanks to Max and
Subject: [REBOL] Re: function to object?
-- snip--
A collegue once described to me his moment of enlightenment when a
professor had drawn on the blackboard a table showing relationships
between some functions and data structures, something like:
|Fn0|Fn1|...|Fnx
Bryan:
When suddenly I wondered, can one convert a function to an object in
rebol?
You can easily *add* a function to an object.
a-function: func [a b /local c] [c: a + b print c]
a-function 19 21 ;; test it works
an-object: make object! [a-function-in-an-object: :a-function]
Am Mittwoch, 5. November 2003 13:53 schrieb bryan:
Am reading a little rant against object orientation
http://www.bluetail.com/~joe/vol1/v1_oo.html
When suddenly I wondered, can one convert a function to an object in
rebol?
means what?
f: func[][alert hi]
o: context[f: none]
o/f: :f
o/f
;?
Hi, Bryan,
bryan wrote:
Am reading a little rant against object orientation
http://www.bluetail.com/~joe/vol1/v1_oo.html
Rant being the operative word. One can tell from the title that
this is somebody venting his spleen and not contributing to any
objective discussion of programming
Thanks for that wonderful post -- all of it !
- Jason
- Original Message -
From: Joel Neely [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 5:26 PM
Subject: [REBOL] Re: function to object?
-- snip--
A collegue once described to me his moment of enlightenment
WAIT shouldn't be a problem except in VID, as Gabriele pointed out. My
little test is very simple, and was based on an FSM engine I built. The
engine itself does event dispatching and, on my P900, processes about
10,000
events/sec. There's no need to WAIT for anything. Just do things in
--- [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I think their special $49 pricing on View/Pro is
gone, so it might be $99
now, but still not an outrageous fee if you need
those features.
--Gregg
However... in this mailing-list many people ask to
Carl to make
free-of-charge some
--- [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
If the two Rebol programs can't communicate
directly,
have them write to a .TXT file, and the other
would look
for keywords do do something, write something else
to
the file, etc,etc.
I have tried and used Rebol for about 2 years
Hi Gregg,
how do you think you can implement multitasking (even cooperative, but
enough efficient, with an enough fast task-switching) in Rebol Core?
Using WAIT instruction? And in View that the documentation suggest NOT
TO USE wait command?
If the standard Rebol/Core (royalty free version,
Hi Alessandro,
On Wednesday, June 12, 2002, 9:13:22 AM, you wrote:
rei how do you think you can implement multitasking (even cooperative, but
rei enough efficient, with an enough fast task-switching) in Rebol Core?
rei Using WAIT instruction? And in View that the documentation suggest NOT
rei
[EMAIL PROTECTED] wrote:
Hi Gregg,
how do you think you can implement multitasking (even cooperative, but
enough efficient, with an enough fast task-switching) in Rebol Core?
Using WAIT instruction? And in View that the documentation suggest NOT
TO USE wait command?
If the standard Rebol/Core
And you can get rugby at www.rebolforces.com/~erebol
--maarten
Gabriele Santilli wrote:
Hi Alessandro,
On Wednesday, June 12, 2002, 9:13:22 AM, you wrote:
rei how do you think you can implement multitasking (even cooperative, but
rei enough efficient, with an enough fast
-pekr- Wrote:
Alessandro - you have to be new here, no? :-) Look, rebol base is just
one - so - even your View contains sound, shell and library components.
They are locked by license key.
Ok... and where is the difference for me?!
I have two options...
1) View does not contain sound,
Thank you!
--Alessandro--
=
Hi Alessandro,
On Wednesday, June 12, 2002, 9:13:22 AM, you wrote:
rei how do you think you can implement multitasking (even
cooperative, but
rei enough efficient, with an enough fast task-switching) in
Hi Alessandro,
2) View contain sound, shell, etc... but they are locked.
I think their special $49 pricing on View/Pro is gone, so it might be $99
now, but still not an outrageous fee if you need those features.
--Gregg
--
To unsubscribe from this list, please send an email to
[EMAIL
If the two Rebol programs can't communicate directly,
have them write to a .TXT file, and the other would look
for keywords do do something, write something else to
the file, etc,etc.
I have tried and used Rebol for about 2 years now (at least,
it seems like 2 years... I first started using it
Hi Mark,
On Tuesday, June 11, 2002, 6:30:46 AM, you wrote:
MC 1) Agree a lot of the function needed can not be implemented well without
MC true multitasking especially a lot of Network programming that need
MC multithreads.
I'd like to point out, that multithreading would only be needed
Hi Gabriele,
I partially agree with you. Multitasking is not needed only to develop
server processes, since there could be many occasions where I should
need more than one process in parallel at-a-time, even in client
applications.
I wish to simplify the life of Rebol developers, so I can say I
Hi Allesandro,
I wish to simplify the life of Rebol developers, so I can say I can use
every instrument to create multiprocesses: multiprocess (like a FORK),
multithread (Ms Windows-style) either preemptive or cooperative (even if
the last one is not the best system... however is a good
Thank you (sigh!).
When a Rebol version will include a multiprocessing/multithreading
feature?! It is a very important feature in a programming language! True
multitasking! Python already does! Java already does! And... how about
low level socket programming? Is Rebol an Internet programming
REBOL has low-level socket programming via ports and set-modes
--Maarten
[EMAIL PROTECTED] wrote:
Thank you (sigh!).
When a Rebol version will include a multiprocessing/multithreading
feature?! It is a very important feature in a programming language! True
multitasking! Python already
Where can I find documentation or infos about it?
REBOL has low-level socket programming via ports and set-modes
--Maarten
[EMAIL PROTECTED] wrote:
Thank you (sigh!).
When a Rebol version will include a multiprocessing/multithreading
feature?! It is a very important feature in a
Network programming: core 2.3 user guide
set-modes: Core 2.5 release notes
--Maarten
[EMAIL PROTECTED] wrote:
Where can I find documentation or infos about it?
REBOL has low-level socket programming via ports and set-modes
--Maarten
[EMAIL PROTECTED] wrote:
Thank you (sigh!).
When a
FWIW, my earlier message on this thread represented an
incorrect understanding; launch can be used in the
console and scripts launched through the console, but
not in scripts invoked via the REBOL command line; not
sure about using the /View interface.
This makes it, as others have noted, less
1) Agree a lot of the function needed can not be implemented well without
true multitasking especially a lot of Network programming that need
multithreads.
2) Low level socket programming is available in Rebol. However, good
proper documentation is not available (or I don't know), making
Hi Allesandro,
I was very interested to the function launch (I didn't know it).
But I didn't find enought documentation about it.
Can someone tell me more about launch refiniments? (this function could
be used to simulate a multiprocessing system!).
Launch is fairly limited in practice
--- Gregg Irwin [EMAIL PROTECTED] wrote:
Hi Allesandro,
I was very interested to the function launch (I
didn't know it).
But I didn't find enought documentation about it.
Can someone tell me more about launch refiniments?
(this function could
be used to simulate a multiprocessing
Hi,
Answering my own message here
got the syntax
view layout [field Test sensor 0x0 keycode [f1] [print f1 pressed]]
Cheers Phil
=== Original Message ===
Hi,
What is the syntax for testing for function keys f1,f2 etc in a sensor?
(I assume it is possible)
Cheers Phil
--
To
Larry Palmiter wrote:
3) function application time
Only after g has been executed, is the word 'a' set to NONE. The local words
in the function only get values when the function is applied. If the values
are determined by the arguments or refinements, or by the use of SET or a
set-word in
Hi Mark
WHY is setting words in functions to 'none by default useful?
When you create the function, all the words (args, refinements, args of
refinements) are binded at a new hidden context and the starting value of
words in context is the unset value.
When you execute the function, all the
Hi Romano,
Romano
(...)
An unset word is a word with the value unset. It is like any other value and
any other word. If you use it where a function ask a value, Rebol triggers
an
error. But Rebol triggers the same error if you pass an argument of type
integer! where a function ask for a value of
Romano,
I understand how and what happens when words which are local to functions are not
defined, they are defined to the 'none value when REBOL evalautes the function,
however my contention is that REBOL should not do this and leave all local words unset
if they are not defined, just as
Hi, Marck
My preference would be all words are defined as local to their context,
including words defined in objects, functions and use contexts. All undefined
words are intitialised to the 'unset value and are testable with the value? or
unset? get/any 'word functions.
Well, a question of
Joel Neeely/ everybody,
perhaps you misunderstood my previous post,
my concern was that uninitialised local words
are treated differently between contexts and
function-contexts.
Please see below,
use [my-word] [print unset? get/any 'my-word]
true
my-func: has [my-word] [print unset? get/any
Hi, Mark,
[EMAIL PROTECTED] wrote:
Joel Neeely [sic]/ everybody,
perhaps you misunderstood my previous post,
Perhaps the wording of the previous post was capable
of being understood in different ways...
my concern was that uninitialised local words
are treated differently between
Hi Mark,
I don't see a reason or logic for the distinction, can anybody please
explain why these contexts are treated differently, as from what I can see it
is possible to use uninitialised words in function contexts, well they're not
actually uninitialised as REBOL sets them to 'none during
Hi Romano,
surely it would be just as easy to test whether local words or refinements are set, ie
with the function Unset? as opposed to none?.
Iam not particularly bothered by this now that I know about it, it was just the oddity
inexplicable difference about it that initially concerned me.
Hi Mark,
surely it would be just as easy to test whether local words or refinements
are set, ie with the function Unset? as opposed to none?.
Mine is only an idea, i'm not sure this is the true reason, but a none value
can be used directly in expression like:
if ref [...]
either ref [][]
that value, otherwise they are set
to NONE.
Cheers
-Larry
- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 04, 2001 1:21 AM
Subject: [REBOL] Re: Function Context Query
Joel Neeely/ everybody,
perhaps you misunderstood my previous post,
my concern
Hi Romano, et al
Mine is only an idea, i'm not sure this is the true reason, but a none
value
can be used directly in expression like:
if ref [...]
either ref [][]
An unset value would generate an error in these cases.
That's exactly what I was thinking. I have no clue about the inner
Hi, Mark
Surely this is incorrect?
a: has [b c] [ print b print c]
a
none
none
a/local 3 4
3
4
Amazing! At least for me!
This demostrates that /local is a refinement like any other, only for
convention it is used for defining local. One can use another one. The only
difference is
Hi, Mark,
[EMAIL PROTECTED] wrote:
Surely this is incorrect?
a: has [b c] [ print b print c]
a
none
none
a/local 3 4
3
4
Surely local words default value should be unset
until they are defined?
Also in the second case is it correct to be
able to pass values to local words
PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 03, 2001 10:07 PM
Subject: [REBOL] Re: Function Context Query
Seems pretty clear:
source has
has: func [
{A shortcut to define a function that has local variables but no
arguments.}
locals [block!]
body [block
From: "Rondon Andrade"
Does anybody has a function do decode post ? I've seen just to decode
cgi-query-string.
Hi, Rondo,
I have several approaches that I've used. One of these does not work with
older versions of REBOL, but I can't seem to remember which right now. The
second example
57 matches
Mail list logo