[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ESPResSo-devel] TCL procedures with variable calling parameters
From: |
Limbach, Hans Joerg, LAUSANNE, NRC-FS |
Subject: |
RE: [ESPResSo-devel] TCL procedures with variable calling parameters |
Date: |
Fri, 26 Oct 2007 14:52:22 +0200 |
Thanks Olaf!
So indeed that might be more clear, but it is also quite lengthy! But
probably one can pack this in a function that handles optional arguments
like
handle_opt_args "p1 p2 p3 p4" "d1 d2 d3 d4" $args
(I guess that can be done using upvar or something similar), that one
then can call at the beginning of a procedure. Of course the additional
features of Olafs suggestion should also be possible.
And don't be afraid. I do not plan to change all interfaces in Espresso,
but I would like to add some stuff where this would be handy, and I
would like to agree on a way how to implement such a feature in a
defined way. Otherwise we end up with as many procedure interfaces as we
have programmers.
Greetings,
Hanjo
> -----Original Message-----
> From: Olaf Lenz [mailto:address@hidden
> Sent: vendredi, 26. octobre 2007 14:24
> To: Limbach,Hans Joerg,LAUSANNE,NRC-FS
> Cc: address@hidden
> Subject: Re: [ESPResSo-devel] TCL procedures with variable
> calling parameters
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi!
>
> Limbach, Hans Joerg, LAUSANNE, NRC-FS wrote:
> > I find it often very anoying that you one always has to
> look for the
> > right order of arguments and in addition that you have to
> give all of
> > them all the time.
>
> Indeed, this is annoying. In general, whenever a Tcl proc has
> optional arguments, a comparable construct is required.
>
> Attached, you'll find a modified version of Hanjos script
> demonstarting the technique that I have been using in the
> pbctools plugin for VMD and also in ESPResSo in
> scripts/vtf.tcl (e.g. for the proc writevcf).
>
> It basically does the same as Hanjos script, but has a number
> of additional features:
> 1. It is more readable (I think).
> 2. It can handle optional arguments with no arguments
> ("switches") or with more than one argument.
> 3. It passes through the mandatory arguments, i.e. after the
> option processing, $args contains the remaining arguments
> that can be handled classically.
>
> Although this is not necessary, I have changed the optional
> arguments to require a "-" in front of it, as is common e.g.
> in Unix commands. This makes it easier to read the proc call,
> as one can distinguish between the optional arguments and the
> mandatory arguments.
>
> > Have a look at it and let me know what you think.
> > I am almost sure that this either might exist already or
> that somebody
> > of you has a better idea how to handle this. In my opinion
> something
> > like this would make Espresso much more user friendly.
>
> You are absolutely right. However, this would require to
> change the UI of most of ESPResSos functions and would render
> all already written scripts invalid! Therefore I think doing
> this change would be something for ES++.
>
> In general, this shows, how important it is to think
> thoroughly about the UI that you give to a new function,
> because it is very hard to change it afterwards, when it is
> already used by many people.
>
> Olaf
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHIdxGtQ3riQ3oo/oRAlwIAJ4lfefzkr/C1/m3KJn3DL8aicdMpACgoYle
> mc5gMmAZ0QBpVie9LLW1mss=
> =KTPG
> -----END PGP SIGNATURE-----
>