#92 $@ and $# expansion (argc, argv)

puredata (385)

the attached patch extends the $-expansion mechanism:

$# expands to the number of arguments; usable both as
A_DOLLAR (just "$#") and A_DOLLSYM ("$#-bla")

$@ expands to the entire list of arguments (e.g. [$@
$@( will expand [1 2 3( to [1 2 3 1 2 3(); this is only
usable as A_DOLLAR; i.e. [symbol $@-a( will always
expand to "$@-a"

well, its a way to deal with dynamic length lists that
is still missing in pd (though 1st steps have been made
with [list])

what is still missing is an expansion for the selector
of messages and objects (the selector of an object
would be the object's instantation name); would $$ be a
good name for this? (since $0 is already taken)


  • IOhannes m zmölnig

    unified diff against pd-0.40-0test03

  • Hans-Christoph Steiner

    Logged In: YES

    Yes! This is great!

    As for the selector, $0 is not taken in message space, so I
    think it makes sense there. Since message expansion
    variables are already different than object arguments, I
    think that won't be too confusing. Plus the $ variable
    syntax comes from shell scripting, where $0 is basically the
    selector of the message that is the command line arguments.

  • IOhannes m zmölnig

    Logged In: YES
    Originator: YES

    updated for current CVSversion of pd (2007-01-02)
    File Added: dollargcargv.patch

  • IOhannes m zmölnig

    unified patch against pd-0.41-0test3 (CVS)

  • Anonymous - 2007-01-13

    Logged In: YES
    Originator: NO

    i think that $@ is what is necessary to allow abstractions to do what they want with args, and that $# is not so useful in comparison, and what would be more useful than $# (in the sense of avoiding more detours) would be to be able to do a $@-like thing that only starts at the Nth argument, e.g. if I have an abstraction that takes $1 $2 $3 and then a variable number of arguments, and those arguments starting with $4 are to be all written directly in an objectbox. witness the strange stuff going on in [nqpoly]...

  • Hans-Christoph Steiner

    This is included in Pd-extended 0.43



Cancel  Add attachments