Re: Non Compulsory Parameters & a Null Constant ?
Re: Non Compulsory Parameters & a Null Constant ?
- Subject: Re: Non Compulsory Parameters & a Null Constant ?
- From: Paul Skinner <email@hidden>
- Date: Wed, 12 Feb 2003 19:43:37 -0500
On Wednesday, February 12, 2003, at 01:05 PM, has wrote:
Adam Hinshaw wrote:
is there a way to specify parameters in a handler that are not
compulsory in
a call to that handler.
Handler parameters are non-optional (annoying, but that's how it is).
You can work around this when you have to:
on doSomething(paramRec)
set {foo:foo, bar:bar} to paramRec & {foo:0, bar:false}
log foo
log bar
end
doSomething({})
doSomething({foo:4})
doSomething({foo:19, bar:true})
It's kinda ugly, but may be the lesser evil when writing handlers that
must have this level of flexibility and self-sufficiency (e.g.
reusable libraries). Rest of the time, it's simpler just to be
explicit:
on doSomething(foo, bar)
...
end
If it'll make your code easier to read/maintain, you can always define
your default values up front as 'constants':
It's kinda ugly, ...snip...
I've heard you express that sentiment before has. I still don't get it.
Perhaps if you picture the braces like this...
GildedScallopShell({Venus:"rising"})
:)
Paul Skinner
--
Life is dying to be born.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.