Re: [NTLK] Methods in the app's base view - how do I actually INVOKE them?

From: Simon Bell <simonbell_at_mac.com>
Date: Sat Oct 04 2008 - 13:27:27 EDT

On 4 Oct 2008, at 17:37, Anthony Martinez wrote:

>> cstr := call kNstrToCstrFunc with ("something");
>
> I saw that in another package and found it to be rather
> inelegant-seeming and verbose.

I agree it’s not what we’re used to seeing as a function call, but
the call-with syntax implies more than that. What’s being called is a
function object, which also knows its environment, so it has access
to the local variables and those inherited by self at the time of the
function object’s creation. The NewtonScript Language document
describes this far better than I can, but the point is that call-with
is much more powerful than a simple function call so I think the
verbosity is worth it.

>> DefGlobalFn('nstrToCstr, kNstrToCstrFunc);
>> ...
>> cstr := nstrToCStr("something");
>
> Which pollutes the global namespace, correct?

Correct. The guidelines say you should make your global function name
unique by appending your developer signature:

DefGlobalFn('|nstrToCstr:MTP|, kNstrToCstrFunc);
...
cstr := |nstrToCstr:MTP|("something");

Not pretty either. I left this out of my original reply because I
thought it would only confuse matters.

I’m sure I speak for most NewtonTalkers when I say I look forward to
reading how you get on with your project!

Simon

====================================================================
The NewtonTalk Mailing List - http://www.newtontalk.net/
The Official Newton FAQ - http://www.splorp.com/newton/faq/
The Newton Glossary - http://www.splorp.com/newton/glossary/
WikiWikiNewt - http://tools.unna.org/wikiwikinewt/
====================================================================
Received on Sat Oct 4 13:29:15 2008

This archive was generated by hypermail 2.1.8 : Sat Oct 04 2008 - 14:30:00 EDT