It is no better to be the man of one language than to be the man of one book. So I am studying C# and find it quite to my taste. No small feat after too much Perl programming:
C feels too low level. C++ is too complicated. Java is just bondage.
The problem with a new language is: one wants his favorite idioms to translate readily. So what about @_ in C#?
I love @_ (and I hate it, but I know how to use a hash ref if I want to have some equivalent of named parameters). The idea is that the caller passes as many parameters as it wants. The caller gets them in @_ and figures out what to do with them.
You knew that. :)
So I was curious to see how this idiom of
using an implicit array translates in C#.
// defining
public int foo ( params Object[] vals ) {
foreach( Object i in vals ) {
...
}
}
// calling
foo( 1, 4);
the
params keyword indicates that an unknown nunber of parameters can be used for the calling of the
function
foo and that they will be available in the callee in the
vals array.
In C you would have to use va_start(),va_arg(), va_end().
Neither Java, nor C++ have foreach keyword, so they must use an explicit iterator object. I am too lazy to write the equivalent Java code. Too ugly.
you may want to read A comparative overview of C#.
-- stefp A unix fan that likes a MS product. Everything happens!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.