A printf wrapper

Guest
Dear skilled cadencers,

I'd like to write a wrapper for the printf() function. The problem is
that I do not know how to have a variable number argument. I tried
with @rest:

procedure( myPrint(port str @rest args)
fprintf(port str args)
newline(port)
)

however this won't work because args is a list and fprintf (or printf)
complains about that.
How can I achieve this task?

Thanks,
mb
 
dear mb,

you can use apply() to make up the list of arguments to pass to a function.

in your example, apply('fprintf append(list(port str) args))

would this do the trick ?

cheers,
Stéphane

marcoballins@gmail.com wrote:
Dear skilled cadencers,

I'd like to write a wrapper for the printf() function. The problem is
that I do not know how to have a variable number argument. I tried
with @rest:

procedure( myPrint(port str @rest args)
fprintf(port str args)
newline(port)
)

however this won't work because args is a list and fprintf (or printf)
complains about that.
How can I achieve this task?

Thanks,
mb
 

Welcome to EDABoard.com

Sponsor

Back
Top