www.digitalmars.com         C & C++   DMDScript  

D - Im sure this has been asked

reply Andrew Nguyen <Andrew_member pathlink.com> writes:
Im sure this has been asked, but why isn't there any generic progeramming
capabilities? I've checked the (SHAKES)/. post, and most of the complaints lay
from the lack of any generic programming capabilities.

Also, howabout the use of {} in another context?

Take this code:

foo(34)
{
//do blah
}

Of course, here, we are not initializing the function. But what I propose is
that the code block is evaluated or run if foo(34) returns a true. 

Another example:

while(i<100)
{
check_iagainstb(i) //if i == b, return 1
{
printf("i is er, equal to b");
}
}
Oct 29 2002
next sibling parent "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
shortcut for

if (foo(34))
{
//do blah
}

Saves like 4 characters.  Is it worth it?  I'd bet it would cause some
ambiguity somewhere in the parser.  And not only that but I doubt Walter
will go for it; it looks similar to functional language constructs.  I'd
personally like at least a ? mark or something sprinkled in occasionally to
clarify the syntax.

foo(34)
{
}

doesn't look like much of a question to me.  It looks too much like a
function declaration and also like a function call.  May be a more
appropriate syntax for anonymous functions?  No, that wouldn't even work.

Sean

"Andrew Nguyen" <Andrew_member pathlink.com> wrote in message
news:apnbvd$2vin$1 digitaldaemon.com...
 Im sure this has been asked, but why isn't there any generic progeramming
 capabilities? I've checked the (SHAKES)/. post, and most of the complaints
lay
 from the lack of any generic programming capabilities.

 Also, howabout the use of {} in another context?

 Take this code:

 foo(34)
 {
 //do blah
 }

 Of course, here, we are not initializing the function. But what I propose
is
 that the code block is evaluated or run if foo(34) returns a true.

 Another example:

 while(i<100)
 {
 check_iagainstb(i) //if i == b, return 1
 {
 printf("i is er, equal to b");
 }
 }
Oct 29 2002
prev sibling parent "Walter" <walter digitalmars.com> writes:
The D support for generic programming is the template support, which is
implemented. The slashdot post is a year out of date <g>. -Walter

"Andrew Nguyen" <Andrew_member pathlink.com> wrote in message
news:apnbvd$2vin$1 digitaldaemon.com...
 Im sure this has been asked, but why isn't there any generic progeramming
 capabilities? I've checked the (SHAKES)/. post, and most of the complaints
lay
 from the lack of any generic programming capabilities.

 Also, howabout the use of {} in another context?

 Take this code:

 foo(34)
 {
 //do blah
 }

 Of course, here, we are not initializing the function. But what I propose
is
 that the code block is evaluated or run if foo(34) returns a true.

 Another example:

 while(i<100)
 {
 check_iagainstb(i) //if i == b, return 1
 {
 printf("i is er, equal to b");
 }
 }
Oct 29 2002