Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined Indirect function specification

May
3,515
5
Existing TCC syntax (actually, even 4DOS syntax) allows the user to specify
the names of environment or internal variables, GOTO and GOSUB labels,
internal and external commands to be used indirectly by the value of a
variable, e.g., %[%xyz] or GOTO x_%xyz. Many times it would be useful to
specify the name of a variable function in an analogous manner (equivalent
to "function pointer" in the C language):

for %f in ( CRC32 MD5 ) echo %f=%@%f[s,%xyz]

If I am mistaken, and such syntax already exists, I'd be very happy to learn
what it is!
--
Steve
 
> Existing TCC syntax (actually, even 4DOS syntax) allows the user to
> specify
> the names of environment or internal variables, GOTO and GOSUB labels,
> internal and external commands to be used indirectly by the value of a
> variable, e.g., %[%xyz] or GOTO x_%xyz. Many times it would be useful
> to specify the name of a variable function in an analogous manner
> (equivalent to "function pointer" in the C language):
>
> for %f in ( CRC32 MD5 ) echo %f=%@%f[s,%xyz]

"Many times" may be overstating the case slightly, since this is the first
request for this in 20 years! (It can in fact be done with existing
variable expansion, though it's not exactly simple or intuitive.)

Do you have real examples of why you need this?

Rex Conn
JP Software
 
| ---Quote---
|| Existing TCC syntax (actually, even 4DOS syntax) allows the user to
|| specify
|| the names of environment or internal variables, GOTO and GOSUB
|| labels, internal and external commands to be used indirectly by the
|| value of a variable, e.g., %[%xyz] or GOTO x_%xyz. Many times it
|| would be useful to specify the name of a variable function in an
|| analogous manner (equivalent to "function pointer" in the C
|| language):
||
|| for %f in ( CRC32 MD5 ) echo %f=%@%f[s,%xyz]
| ---End Quote---
| "Many times" may be overstating the case slightly, since this is the
| first request for this in 20 years!

Having my doctorate in laziness and procastrination, never having requested
it before just means that I never bothered to put my desires in writing.
This time I had been in the mood to submit suggestions, and this was just
one.

| (It can in fact be done with existing variable expansion, though it's not
| exactly simple or intuitive.)

Please provide an example!

| Do you have real examples of why you need this?

Yes - see the failing syntax in my OP. In fact the example is exactly what I
wanted to do: create a command line (or alias or batch file) which reports
the various hash codes for a string parameter. Why not "unroll the loop"?
Because in loop form each new function needs to be added to the enumeration
only once, keeping it simple.
--
Steve
 

Similar threads

Back
Top