THE number of...

erik hansen erikhans08 at yahoo.com
Mon Jan 14 02:38:01 EST 2002


--- "J. Landman Gay" <jacque at hyperactivesw.com>
wrote:
> erik hansen wrote:
> 
> > put tot(it,l) into tot
> > shorter
> > put (the number of lines in it) into tot
> > clearer
> > 
> > only thing is, nobody else does this.
> > maybe clearer is better than shorter?
> 
> Depends. In this case, the clearer method takes
> less time to execute
> too, so it's probably better. MC has to get the
> number of lines (or
> items, or whatever) no matter which method you
> use, but it takes extra
> time to load up the custom function's
> parameters, send it, and get the
> results back. So by moving a single native MC
> statement to a custom
> function, execution time is increased. Leaving
> the function inside the
> handler is marginally faster. (MC is so fast in
> general though that the
> difference in this case would be miniscule.)
> 
> In other cases, calling out to a function might
> be better, especially if
> the function is long or complex, or if it does
> something that several
> different handlers need to use. A custom
> function call makes scripts
> easier to read in that case. There's always a
> balancing act between
> readability and functionality though, and
> everyone has their own preferences.
> 
> There is a difference between MC and HC when
> calling native functions.
> In HC, functions written with "the" are sent
> directly to HyperCard,
> while functions that use parentheses traverse
> the message hierarchy.
> That means it matters which way you write them;
> if you write them with
> parentheses, they take longer but they can be
> trapped later on in a
> handler farther up the hierarchy (not a great
> scripting technique, but
> it can be done.) On the other hand, MC sends
> all its native commands and
> functions directly to the engine; that's why
> you can't intercept and
> trap any MC keywords. So in MetaCard, it
> doesn't matter whether you
> write "the length of thisWord" or
> "length(thisWord"), they are equivalent.

aaaaahhhh! i just did all "the"s. maybe if a goal
is using handlers to teach programming, or at
least how to FOLLOW programming, then the more
english-like the better.

this was funny: while substituting
"tot(l," for "(the number of lines in "
i pasted INSIDE function tot.
HyperCard crashed. the mac crashed.

can anyone identify the "too much recursion"
culprit?"

function tot what,it
  if what is "t" then
    put the itemdelimiter into saved
    set the itemdelimiter to ","
    return (the number of items in it)
    set the itemdelimiter to saved
  else if what is "l" then 
    return tot(l,it)
  else if what is "w" then
    return (the number of words in it)
  else
    debug checkpoint
  end if
end tot


=====
erik at erikhansen.org                 http://www.erikhansen.org

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/



More information about the metacard mailing list