Trying a custom handler for several math fields

Geoff Canyon gcanyon at gmail.com
Sun Sep 15 14:53:59 EDT 2013


In the absence of confirmation from someone looking at the engine code, I
wrote a test. Here are two handlers, with comments explaining what I think
is going on:

on mouseUp
   put 1 into X -- X is a number
   put 1 into Y -- Y is a number
   put the long seconds into T
   repeat 9999999
      put X into Z -- Z is a number, no conversion
      add Z to Y -- Z is a number, no conversion
   end repeat
   put the long seconds - T
end mouseUp


on mouseUp
   put "1" into X -- X is a string
   put 1 into Y -- Y is a number
   put the long seconds into T
   repeat 9999999
      put X into Z -- after the first loop, each time Z has to convert back
to a string
      add Z to Y -- Z has to be converted to a number
   end repeat
   put the long seconds - T
end mouseUp

On my mac, the second handler consistently takes 10% longer to run. Since
the handlers are otherwise identical, I have to think string conversion is
causing the slowdown, and that in the first handler, nothing is being
stored as a string.

gc


On Sat, Sep 14, 2013 at 11:08 PM, <dunbarx at aol.com> wrote:

> Geoff.
>
>
> I could be misRemembering, possibly even in an earlier life (HC), that
> variable typing was done by the interpreter at runtime, or in HC 2, at
> compile time.
>
>
> Maybe this was changed in LC? Someone here must know...
>
>
> Craig
>
>
>
> -----Original Message-----
> From: Geoff Canyon <gcanyon at gmail.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Sent: Sat, Sep 14, 2013 9:10 pm
> Subject: Re: Trying a custom handler for several math fields
>
>
> (We agree on all your other points)
>
> I remember reading many years ago on this mailing list that if you assign a
> number  to a variable:
>
> put 52 into x
>
> LC stores that variable as a number from the get-go and only converts it
> to a
> string if needed.
>
> Sent from my iPad
>
> On Sep 14, 2013, at 9:22 AM, dunbarx at aol.com wrote:
>
> > If you add a number to "50", it is then that the engine types the string
> as a
> number.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list