[REBOL] Rebol's function argument specification dialect
From: andrew::martin::colenso::school::nz at: 24-Dec-2003 22:44
Steven wrote (in another thread):
> ADD-FILLER: func [
> "Add a specified number of blanks to FORMATTED-LINE"
> SPACE-COUNT integer!
> ] [
And why didn't Rebol pick up the fact that 'integer! should have been
inside square brackets? Because, sometimes, you want a function that
takes a data-type! Value, as per below:
>> source collect
collect: func [
"Collects the results of block evaluations."
Block [block!] "The block to 'do."
/Only "Inserts the result as a series."
/Full "Don't ignore none! values."
/Initial Type [series! datatype!] "Specifies the type of the
use [Break Result Results] [
Break: func [
"Breaks out of the 'Collect."
/Return "Forces the loop function to return a Value."
system/words/break/return either Return [
Results: any [
make Type 0
if not any [
unset? set/any 'Result do [(bind Block 'Break)]
(pick [[none? :Result] ] not Full)
(pick [insert insert/only] not Only) tail Results
Admittedly this is the first function that uses a data-type as an
argument, but I'm sure that Joel can think of many more! :)
I wonder if it's a good idea for 'func and it's relatives to insist on
some sort of data-type specification for each argument? It also might be
an idea for the return argument to be specified as well. Or would this
be "too much" for Rebol? In that it doesn't adhere to Rebol's ideal form
as perceived by us all?
Andrew J Martin
Speaking in tongues and performing miracles.
Colenso High School
Arnold Street, Napier.
Tel: 64-6-8310180 ext 826
DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally
liable) for materials distributed to or acquired from user e-mail accounts. You can report
misuse of an e-mail account to our ICT Manager and the complaint will be investigated.
(Misuse can come in many forms, but can be viewed as any material sent/received that
indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate
language and/or other issues described in our Acceptable Use Policy.)
All outgoing messages are certified virus-free by McAfee GroupShield Exchange 5.10.285.0
Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]