On Thu, May 18, 2017 at 5:01 AM, Alan Tilson via 4D_Tech <
[email protected]> wrote:

> Chuck and everyone,
> I don't suppose that there a way to use pointers to methods rather than
> using text method names in things like execute method or new process?
>

No, there's nothing like that in 4D. They're just dead strings. There is a
*lot* that 4D (or we with a bunch of work) could/can do with effort. I
posted a feature request along these lines (vote it up!) some time back:

Compiler/Typing Improvements: Detect some runtime errors in advance
http://forums.4d.fr/Post/EN/19107688/1/19107689

I thought that this request would generate a lot of other ideas and comment
but, well, it hasn't. In it I ask for a fairly modest set of changes to the
compiler that could make a *huge* difference to code quality. Really, it's
about making the compiler far more useful. For example:

1) Provide a syntax to declare a parameter as optional:

C_TEXT($1;Is Optional)

2) Verify that method names passed as arguments are valid:

ON ERR CALL("OhWaitIDeletedThisMethod")

4D knows which arguments are method names. It can check these already. It
just doesn't for some reason.

3) Give us a way to declare parameters as method names:

C_METHOD_NAME($1)

Or

C_TEXT($1;Is Method Name)

Would these method name checking features help with dynamic methods or
formulas created at runtime? No. The compiler can only see static code. Yet
so much of this stuff is typically visible in the code at rest. At the
moment, the only alternative is to write your own code scanner to do static
code analysis. It's entirely doable, it's not a ginormous task, but it is a
fair bit of work.

It would be great if 4D would hand us a parse tree instead of a block of
text for a method. (Well, as another option.) The details of the whitespace
in the text seems to change between versions too, which is a pain. By a
"parse tree", I mean a tree that contains all of the code in the method
broken down by line and within line by part. *The interpreter already does
this internally.* It has to in order to execute code.

But, no, we don't have anything like "members", function pointers,
closures, or objects. You can get some nice results using a V16 worker as a
special sort of namespaced container with private-ish methods...but that's
not really a deliberate design from 4D...it's just a side-effect.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to