va_list equivalent

V

Volte

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:

Code:
Header:
void addLine(int, const char*, ...);

cpp:
addLine(int line, const char *string, ...) {
char *output;
va_list args;
va_start(args, string);
vasprintf(&output, string, args);
va_end(args);
}

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.
 
R

RobG

Volte said:
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:

Code:
Header:
void addLine(int, const char*, ...);

cpp:
addLine(int line, const char *string, ...) {
	char *output;
	va_list args;
	va_start(args, string);
	vasprintf(&output, string, args);
	va_end(args);
}

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.

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;
rpt = x;
if ( 'string' == x || 'number' == x ){
rpt += ': ' + arguments;
}
}
alert('There were ' + len + ' arguments passed to the function:'
+ '\n' + rpt.join('\n')
);
}

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

Evertjan.

Volte wrote on 09 mei 2006 in comp.lang.javascript:
Please read the reply RobG made prior to the post you're replying to.

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

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

Dr John Stockton

JRS: In article <[email protected]>
, dated Mon, 8 May 2006 15:13:34 remote, seen in
news:comp.lang.javascript said:
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.
 
V

Volte

Dr said:
JRS: In article <[email protected]>
, dated Mon, 8 May 2006 15:13:34 remote, seen in


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.

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.
 
R

Richard Cornford

This was highly uncalled for. I am new to this, and such an
attitude has negative helpfulness attached to it.

It also has positive aspects to it. You will find reading this group's
FAQ helpful and informative. ( said:
Leave your national insults
off usenet, there is no need for that here.

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.
Can a moderator please lock this thread? It has degenerated
from its original intent, and my question has already been
answered:

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.
 
L

Lasse Reichstein Nielsen

Volte said:
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.

I can agree with that.
Can a moderator please lock this thread?

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
:)
It has degenerated from its original intent, and my question has
already been answered:

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
 
V

Volte

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

It's true, and I did read it, I was a bit upset about his comment that
I overlooked the helpful remark. My apologies.
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.


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.

Understood, thanks for the information. :)

Cheers.
 
R

Randy Webb

Volte said the following on 5/9/2006 7:01 PM:
This was highly uncalled for.

Absolutely agreed.
I am new to this, and such an attitude has negative helpfulness attached
to it.

Agreed again.
Leave your national insults off usenet, there is no need for that here.

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.
Can a moderator please lock this thread? It has degenerated from its
original intent, and my question has already been answered:

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

Randy Webb

Richard Cornford said the following on 5/9/2006 7:43 PM:
It also has positive aspects to it.

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.
You will find reading this group's FAQ helpful and informative.
(<URL: http://jibbering.com/faq/ >)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top