Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

Variable argument functions

Last post 04-13-2008, 2:21 AM by hatseflats. 2 replies.
Sort Posts: Previous Next
  •  04-12-2008, 2:12 PM 2453

    Variable argument functions

    Hi, I just picked up Squirrel a few days ago, and so far I'm quite impressed with the language basics and possibilities. One of the things I did however find were a bit odd was how variable arguments are handled in functions, specifically that the varg[cv] 'variables' are not real objects. Wouldn't it be easier to extend the syntax of functions so that I could do something like:

    function test(a, b, c = ...) {
    foreach(slot, value in c) {
    // code
    }
    }

    If only two arguments are passed to test c will exist as an empty table, otherwise it should behave like vargv does now.

    Although this changes relatively little, I think it helps in keeping the language a more consistent. Also, because the default value for 'c' is defined at runtime, it shouldn't pose problem implementation wise, I think.

    Anyway, just my 2 cents, if anyone thinks I'm just shouting random junk, please hit me with an over sized trout or something in the spirit thereof :)
  •  04-13-2008, 1:05 AM 2454 in reply to 2453

    Re: Variable argument functions

    Hi, I agree with you, but you arrive late, I already planned this change for squirrel 3.x. Look at this post http://squirrel-lang.org/forums/thread/2403.aspx 

    ciao

    Alberto

  •  04-13-2008, 2:21 AM 2455 in reply to 2454

    Re: Variable argument functions

    Heh, I guess I should search around the forum a bit harder next time I come up with an idea. Thanks for the info

    Rudolf
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems