Hello Gabriele,
On 03-Feb-00, [EMAIL PROTECTED] wrote:
> Hello [EMAIL PROTECTED]!
>
> On 02-Feb-00, you wrote:
>
>> my-function: func [
>> "My function"
>> a [string!] "required argument"
>> /b "A refinement"
>> c: "Hello" [string!] {An optional argument with the
>> default value "Hello"} ] [
>> print mold [a c]
>> ]
>
> Thomas, this is a nice idea. I think RT may want to add something
> like this in the future.
I hope so :-)
> Just a sidenote: in very simple cases, it is possible to write:
>
> f: func [
> a
> /b c
> ] [
> c: any [c "default"]
> ...
> ]
Thanks for the tip, better to use 'any than the way I did it,
but note that the above translates to something like (in my 'tagfunc):
f: func [
a
/b
/c c-value
] [
c: any [c-value "default"]
...
]
My main motivation for writing this function, was to ease writing and
calling functions with many arguments.
considering a 'func called create-bitmap
create-bitmap: func [
width: 128
height: 128
scheme: 'rgb
bpp: 24
...
] [
...
]
you could call it with
1) create-bitmap ; default values automatically loaded!
or
2) create-bitmap/width/height/scheme/bpp 320 200 'grey 8
or
3) create-bitmap/tags [width: 320 height: 200 scheme: 'grey bpp: 8]
or
4) create-bitmap/tags [
width: 320
height: 200
scheme: 'grey
bpp: 8
]
I personally prefer 3 and 4 over 2.
I'll try to come up with a better example later...
Best regards
Thomas Jensen