Connecting Tech Pros Worldwide Forums | Help | Site Map

va_list equivalent

Volte
Guest
 
Posts: n/a
#1: May 7 '06
Hey, wondering if there is a va_list equivalent in Javascript. Well,
actually, I know that there is, but I don't know if its user...
applicable. va_list in C/++ anyhow is a way of being able to pass in
any number of arguments at the end of a function, I'll show an example:

Expand|Select|Wrap|Line Numbers
  1. Header:
  2. void addLine(int, const char*, ...);
  3.  
  4. cpp:
  5. addLine(int line, const char *string, ...) {
  6. char *output;
  7. va_list args;
  8. va_start(args, string);
  9. vasprintf(&output, string, args);
  10. va_end(args);
  11. }
  12.  
So as you can see, the space is reserved at the end of the function
declaration with the "..." syntax, and in the function body is expanded
and processed. I could be way off here, but I think I'm on the right
track. Thanks for the help.

Cheers.


RobG
Guest
 
Posts: n/a
#2: May 7 '06

re: va_list equivalent


Volte wrote:[color=blue]
> Hey, wondering if there is a va_list equivalent in Javascript. Well,
> actually, I know that there is, but I don't know if its user...
> applicable. va_list in C/++ anyhow is a way of being able to pass in
> any number of arguments at the end of a function, I'll show an example:
>
>
Expand|Select|Wrap|Line Numbers
  1. > Header:
  2. > void addLine(int, const char*, ...);
  3. >
  4. > cpp:
  5. > addLine(int line, const char *string, ...) {
  6. >     char *output;
  7. >     va_list args;
  8. >     va_start(args, string);
  9. >     vasprintf(&output, string, args);
  10. >     va_end(args);
  11. > }
>
> So as you can see, the space is reserved at the end of the function
> declaration with the "..." syntax, and in the function body is expanded
> and processed. I could be way off here, but I think I'm on the right
> track. Thanks for the help.[/color]

I guess you are referring to the arguments object. It's a list of the
arguments passed to the function:

function blah()
{
var x;
var rpt = [];
for (var i=0, len=arguments.length; i<len; ++i){
x = typeof arguments[i];
rpt[i] = x;
if ( 'string' == x || 'number' == x ){
rpt[i] += ': ' + arguments[i];
}
}
alert('There were ' + len + ' arguments passed to the function:'
+ '\n' + rpt.join('\n')
);
}

blah('arg1',3,{});



--
Rob
Volte
Guest
 
Posts: n/a
#3: May 8 '06

re: va_list equivalent


Awesome thats what I was looking for! Thanks :)

Evertjan.
Guest
 
Posts: n/a
#4: May 8 '06

re: va_list equivalent


Volte wrote on 08 mei 2006 in comp.lang.javascript:
[color=blue]
> Awesome thats what I was looking for! Thanks :)[/color]

What were you looking for?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Volte
Guest
 
Posts: n/a
#5: May 8 '06

re: va_list equivalent


Please read the reply RobG made prior to the post you're replying to.

Evertjan.
Guest
 
Posts: n/a
#6: May 9 '06

re: va_list equivalent


Volte wrote on 09 mei 2006 in comp.lang.javascript:
[color=blue]
> Please read the reply RobG made prior to the post you're replying to.
>[/color]

There is no "prior" on usenet, that depends on the individual readers news-
server.

So please quote what you are replying on. [second request]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dr John Stockton
Guest
 
Posts: n/a
#7: May 10 '06

re: va_list equivalent


JRS: In article <1147126414.239939.260210@y43g2000cwc.googlegroups .com>
, dated Mon, 8 May 2006 15:13:34 remote, seen in
news:comp.lang.javascript, Volte <Voltechs@gmail.com> posted :[color=blue]
>Please read the reply RobG made prior to the post you're replying to.[/color]

Please read the newsgroup FAQ (via sig line 3 below), particularly
Section 2.3, especially paragraphs 6 & 7 ; by understanding the medium
you have chosen to use, you will get better results.

Google have merely provided an interface to the medium, designed for
Americans of inadequate intellect.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Volte
Guest
 
Posts: n/a
#8: May 10 '06

re: va_list equivalent



Dr John Stockton wrote:[color=blue]
> JRS: In article <1147126414.239939.260210@y43g2000cwc.googlegroups .com>
> , dated Mon, 8 May 2006 15:13:34 remote, seen in
> news:comp.lang.javascript, Volte <Voltechs@gmail.com> posted :[color=green]
> >Please read the reply RobG made prior to the post you're replying to.[/color]
>
> Please read the newsgroup FAQ (via sig line 3 below), particularly
> Section 2.3, especially paragraphs 6 & 7 ; by understanding the medium
> you have chosen to use, you will get better results.
>
> Google have merely provided an interface to the medium, designed for
> Americans of inadequate intellect.
>
> --
> © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
> <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
> <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
> <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.[/color]

This was highly uncalled for. I am new to this, and such an attitude
has negative helpfulness attached to it. Leave your national insults
off usenet, there is no need for that here. Can a moderator please lock
this thread? It has degenerated from its original intent, and my
question has already been answered:

Cheers.

Richard Cornford
Guest
 
Posts: n/a
#9: May 10 '06

re: va_list equivalent


Volte wrote:[color=blue]
> Dr John Stockton wrote:[color=green]
>> JRS: In article
>> Volte posted :[color=darkred]
>>> Please read the reply RobG made prior to the post you're
>>> replying to.[/color]
>>
>> Please read the newsgroup FAQ (via sig line 3 below),
>> particularly Section 2.3, especially paragraphs 6 & 7;
>> by understanding the medium you have chosen to use,
>> you will get better results.
>>
>> Google have merely provided an interface to the medium,
>> designed for Americans of inadequate intellect.[/color][/color]
<snip>[color=blue]
> This was highly uncalled for. I am new to this, and such an
> attitude has negative helpfulness attached to it.[/color]

It also has positive aspects to it. You will find reading this group's
FAQ helpful and informative. (<URL: http://jibbering.com/faq/ >)
[color=blue]
> Leave your national insults
> off usenet, there is no need for that here.[/color]

That is certainly something that I would prefer to see less of. Any
blanket generalisation about a nation or its people is bound to be
false, and almost certainly counter-productive in an international
forum.
[color=blue]
> Can a moderator please lock this thread? It has degenerated
> from its original intent, and my question has already been
> answered:[/color]

The comp.lang.javascript Usenet newsgroup is open, public and
unmoderated. Threads are never really closed, they just stop being
interesting after some unpredictable point. It is also worthless to
attempt to direct the discussion that follows an OP.

Richard.


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#10: May 10 '06

re: va_list equivalent


"Volte" <Voltechs@gmail.com> writes:
[color=blue]
> This was highly uncalled for. I am new to this, and such an attitude
> has negative helpfulness attached to it. Leave your national insults
> off usenet, there is no need for that here.[/color]

I can agree with that.
[color=blue]
> Can a moderator please lock this thread?[/color]

No, sorry, that's not possible. This newsgroup is not moderated. There
are no moderators.

The first sentence of Dr Stockton's post was purely informative and
good advice. The FAQ section 2.3,
<URL:http://www.jibbering.com/faq/#FAQ2_3> is recommended reading,
especially if you are new to Usenet or even just to this group.

Obviously the entire FAQ is recommended reading, that's why it's there
:)
[color=blue]
> It has degenerated from its original intent, and my question has
> already been answered:[/color]

Usenet is a discussion forum. It happens all the time that people
stray from the original subject of a thread, and there is nothing
wrong with that. If the topic changes too severely, the subject
field migh be changed, but it's not really required. The original
poster does not own the thread and cannot control what people
end up discussing (and trust me, many have tried :).

So, welcome. Hope you could use your answer.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Volte
Guest
 
Posts: n/a
#11: May 10 '06

re: va_list equivalent



Richard Cornford wrote:[color=blue]
> It also has positive aspects to it. You will find reading this group's
> FAQ helpful and informative. (<URL: http://jibbering.com/faq/ >)[/color]

It's true, and I did read it, I was a bit upset about his comment that
I overlooked the helpful remark. My apologies.
[color=blue]
>[color=green]
> > Leave your national insults
> > off usenet, there is no need for that here.[/color]
>
> That is certainly something that I would prefer to see less of. Any
> blanket generalisation about a nation or its people is bound to be
> false, and almost certainly counter-productive in an international
> forum.
>[color=green]
> > Can a moderator please lock this thread? It has degenerated
> > from its original intent, and my question has already been
> > answered:[/color]
>
> The comp.lang.javascript Usenet newsgroup is open, public and
> unmoderated. Threads are never really closed, they just stop being
> interesting after some unpredictable point. It is also worthless to
> attempt to direct the discussion that follows an OP.
>
> Richard.[/color]

Understood, thanks for the information. :)

Cheers.

Randy Webb
Guest
 
Posts: n/a
#12: May 10 '06

re: va_list equivalent


Volte said the following on 5/9/2006 7:01 PM:[color=blue]
> Dr John Stockton wrote:[color=green]
>> JRS: In article <1147126414.239939.260210@y43g2000cwc.googlegroups .com>
>> , dated Mon, 8 May 2006 15:13:34 remote, seen in
>> news:comp.lang.javascript, Volte <Voltechs@gmail.com> posted :[color=darkred]
>>> Please read the reply RobG made prior to the post you're replying to.[/color]
>> Please read the newsgroup FAQ (via sig line 3 below), particularly
>> Section 2.3, especially paragraphs 6 & 7 ; by understanding the medium
>> you have chosen to use, you will get better results.
>>
>> Google have merely provided an interface to the medium, designed for
>> Americans of inadequate intellect.
>>[/color]
> This was highly uncalled for.[/color]

Absolutely agreed.
[color=blue]
> I am new to this, and such an attitude has negative helpfulness attached
> to it.[/color]

Agreed again.
[color=blue]
> Leave your national insults off usenet, there is no need for that here.[/color]

100% correct. But after about 7 or 8 years, I have gotten so used to
JRS' pedantic crap that it doesn't bother me anymore, it just provides
me with daily humor is all.
[color=blue]
> Can a moderator please lock this thread? It has degenerated from its
> original intent, and my question has already been answered:[/color]

Whether fortunate or unfortunate, this group isn't moderated and a
thread can't be "locked".

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb
Guest
 
Posts: n/a
#13: May 10 '06

re: va_list equivalent


Richard Cornford said the following on 5/9/2006 7:43 PM:[color=blue]
> Volte wrote:[color=green]
>> Dr John Stockton wrote:[color=darkred]
>>> JRS: In article
>>> Volte posted :
>>>> Please read the reply RobG made prior to the post you're
>>>> replying to.
>>> Please read the newsgroup FAQ (via sig line 3 below),
>>> particularly Section 2.3, especially paragraphs 6 & 7;
>>> by understanding the medium you have chosen to use,
>>> you will get better results.
>>>
>>> Google have merely provided an interface to the medium,
>>> designed for Americans of inadequate intellect.[/color][/color]
> <snip>[color=green]
>> This was highly uncalled for. I am new to this, and such an
>> attitude has negative helpfulness attached to it.[/color]
>
> It also has positive aspects to it.[/color]

There is no "positive aspects" to John's repeated display of bigotry
towards a nation or its people and I don't think the reference to the
FAQ is what was uncalled for.
[color=blue]
> You will find reading this group's FAQ helpful and informative.
> (<URL: http://jibbering.com/faq/ >)[/color]

Absolutely. Thats why I post the URL every time I post here :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Closed Thread