Signatures and option specs [was: Open and pipe]
On Mon, May 02, 2005 at 09:52:35PM +0200, Juerd wrote: I already suggested a syntax like '+$write|w' for having multiple ways to say the same thing. I don't like an explicit :mode. Let Perl figure that out based on passed named arguments. I'd like to see this specced. What you're suggesting is that sub signatures have something as powerful as a good getopt library; things that spring to mind at this prospect are: * canonical representations (eg, :w in your example should probably set $write) * mutually exclusive options (for open modes, :write should exclude :append) * computed options (if by let Perl figure that out $mode you didn't mean let perl's open figure it out with explicit code). How would you suggest formalizing these? (By the way, we need a spec for perl's command line, too. So far we've been emulating perl5's in an ad-hoc manner.) -- Gaal Yahas [EMAIL PROTECTED] http://gaal.livejournal.com/
Re: Signatures and option specs [was: Open and pipe]
Gaal Yahas skribis 2005-05-04 13:48 (+0300): * canonical representations (eg, :w in your example should probably set $write) Or, possibly, $w := $write. * mutually exclusive options (for open modes, :write should exclude :append) I don't really care if this goes in the signature. Runtime checking is good enough for this. sub foo (+$write, +$append) { fail ... if $write and $append; ... } Although I don't think this particular check is needed at all, as append isn't quite opening the file read-only. Just ignore that :write was also given. * computed options (if by let Perl figure that out $mode you didn't mean let perl's open figure it out with explicit code). I did mean let open figure it out. That is, let open decide based on the named arguments it gets how to open something. Let *it* find a way to specify 'a+' and stuff like that, so we can write it readably. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html