On 12/05/2012 05:38 AM, John P. Rouillard wrote:
>
> Hi Risto and all:
>
> I have been looking at the 2.7 alpha release and I have a few
> comments. The functions that deal with setting a variables from some
> context seem to have different calling conventions
>
>      copy, empty, pop, shift
>
> all take "<name>  %<var>" as arguments while:
>
>      exists, getsize, getaliases, getltime, getctime
>
> take "%<var>  <name>". Is there a reason for this discrepency? I can
> see getting really confused about which goes where depending on the
> function. I would suggest making all of them consistant and use
> "<name>  %<var>" for all the functions above.

One of the reasons was that there are already getwpos and setwpos 
actions which record/set the operation window position into/from its 
first variable operand:

getwpos %<var> <offset> [<string>]
setwpos <time> <offset> [<string>]

getctime and setctime do exactly the same things for the context, so it 
seemed a better idea to have the same operand ordering.

When you look at copy, empty, pop, shift, these actions work on event 
data stored to contexts, while exists, getsize, getaliases, getltime, 
getctime are about getting or setting metadata information for contexts. 
Initially, I was actually using a reverse ordering in one intermediate 
release, but become fairly confused by it :(
Finally, it looked a better idea to me to have all actions which query 
or set metadata have the same layout.

>
> Functions like assign, eval, call or lcall sensibly have the variable
> as the first argument since the second argument is potentially
> multiple words long (a string and perl code, param lists etc).
>
> Also to make while/if more useful I think a shortcut like:
>
>     if exists(<name>) ( action_list ) else ( action_list2 )
>
>     while exists(<name>) ( action_list )
>
> is more readable compared to:
>
>     exists<name>  %B; if %B ( action_list ) else ( action_list2 )
>
>     exists<name>  %B; while %B ( action_list; exists<name>  %B )
>
> In general maybe any function that sets a variable can return that
> value for an if or while condition clause. So 'exists' can be replaced
> by 'getsize', 'getaliases', 'pop', 'getltime' ....

To clarify a bit why only action list variables are allowed for 'if' and 
'while' -- initially I was thinking of allowing any constructs which 
would go through substitution or other intepretation, but this would 
again add run time complexity. Depending on the type of an argument, you 
would have to do a number of if-elsif's inside perl code, which slows 
down the code. Moreover, doing variable substitutions is always an 
expensive process.

While things above would be somehow manageable for 'if', imagine now the 
case for 'while' action. For example, the substitutions would have to be 
carried out repeatedly, but since substituted values could contain 
substrings which look like match variables, they would have to be masked 
separately, before actual substitution, etc.

In contrast, action list variables are implemented as a hash table, so 
verifying if an action list variable evaluates true is as simple as:
exists($hash{$var}) && $hash{$var}

These checks are fast and efficient even if the while loop gets executed 
many times. Moreover, there is no need to deal with logical 
contradictions at which point which thing should be masked or substituted.

So the current approach is mainly motivated by simplicity of design and 
efficient execution.

with kind regards,
risto

>
> --
>                               -- rouilj
> John Rouillard
> ===========================================================================
> My employers don't acknowledge my existence much less my opinions.
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
>


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to