Jump to page: 1 24  
Page
Thread overview
#if, #else, #assert and #is
Jun 21, 2005
James McComb
Jun 21, 2005
Derek Parnell
Jun 21, 2005
Lionello Lunesu
Jun 21, 2005
Nod
Jun 21, 2005
clayasaurus
Jun 21, 2005
Tom S
Jun 22, 2005
James Dunne
Jun 22, 2005
Eugene Pelekhay
Jun 22, 2005
Nod
Jun 23, 2005
Andrew Fedoniouk
Jun 24, 2005
Lionello Lunesu
Jun 25, 2005
Walter
Jun 28, 2005
Lionello Lunesu
Jun 29, 2005
Stewart Gordon
Jun 23, 2005
Matthias Becker
Jun 23, 2005
Lionello Lunesu
Jun 23, 2005
pragma
Jun 23, 2005
Derek Parnell
Jun 23, 2005
Derek Parnell
Jun 23, 2005
Regan Heath
Jun 24, 2005
Derek Parnell
Jun 23, 2005
Regan Heath
Jun 24, 2005
Walter
Jun 24, 2005
pragma
Jun 23, 2005
Derek Parnell
Jun 24, 2005
Walter
Jun 24, 2005
Derek Parnell
Jun 24, 2005
Walter
Jun 24, 2005
Derek Parnell
Jun 25, 2005
Walter
Jun 24, 2005
James McComb
Jun 24, 2005
Walter
Jun 24, 2005
Dave
Jun 24, 2005
Lionello Lunesu
Jun 26, 2005
Regan Heath
June 21, 2005
What about this? Instead of:

static if() {}
else

What about:

#if() {} // static if
#else () {} // static else

If would be easy to write code mixing #if, if, #else and else without confusing them.

Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:

#assert() {} // instead of static assert
#is() {} // instead of iftype, or the 'static' is
         // (there would be both is and #is)

It would be easy to extend this so that other functions have both compile-time and run-time versions.

What do you think?

James McComb

P.S. Maybe these should change (for consistency):

#pragma() {} // instead of pragma
#debug() {} // instead of debug
#version() {} // instead of version






June 21, 2005
On Tue, 21 Jun 2005 12:56:01 +1000, James McComb wrote:

> What about this? Instead of:
> 
> static if() {}
> else
> 
> What about:
> 
> #if() {} // static if
> #else () {} // static else
> 
> If would be easy to write code mixing #if, if, #else and else without confusing them.
> 
> Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
> 
> #assert() {} // instead of static assert
> #is() {} // instead of iftype, or the 'static' is
>           // (there would be both is and #is)
> 
> It would be easy to extend this so that other functions have both compile-time and run-time versions.
> 
> What do you think?
> 
> James McComb
> 
> P.S. Maybe these should change (for consistency):
> 
> #pragma() {} // instead of pragma
> #debug() {} // instead of debug
> #version() {} // instead of version

Yes, this is the sort of thing I was thinking of. It would enhance the legibility of code immensely. It quickly signals a compile-time activity and is hard to confuse with run-rime statements. It greps well too.

-- 
Derek
Melbourne, Australia
21/06/2005 1:07:45 PM
June 21, 2005
I have to agree..

It's a great a idea to put this functionality in the language, instead of a seperate preprocess step, but to make it look like normal code is merely confusing.

Furthermore, any fancy IDE will want to use a different color for the highlighting of these 'preprocessor' commands, which might be tricky in the case of "static if ... else".

L.

"James McComb" <ned@jamesmccomb.id.au> wrote in message
news:d97vjn$20lk$1@digitaldaemon.com...
| What about this? Instead of:
|
| static if() {}
| else
|
| What about:
|
| #if() {} // static if
| #else () {} // static else
|
| If would be easy to write code mixing #if, if, #else and else without
| confusing them.
|
| Other 'static functions' that evaluate compile-time expressions could
| use this pragma-style syntax, e.g:
|
| #assert() {} // instead of static assert
| #is() {} // instead of iftype, or the 'static' is
|          // (there would be both is and #is)
|
| It would be easy to extend this so that other functions have both
| compile-time and run-time versions.
|
| What do you think?
|
| James McComb
|
| P.S. Maybe these should change (for consistency):
|
| #pragma() {} // instead of pragma
| #debug() {} // instead of debug
| #version() {} // instead of version
|
|
|
|
|
|


June 21, 2005
In article <d97vjn$20lk$1@digitaldaemon.com>, James McComb says...
>
>What about this? Instead of:
>
>static if() {}
>else
>
>What about:
>
>#if() {} // static if
>#else () {} // static else
>
>If would be easy to write code mixing #if, if, #else and else without confusing them.
>
>Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
>
>#assert() {} // instead of static assert
>#is() {} // instead of iftype, or the 'static' is
>          // (there would be both is and #is)
>
>It would be easy to extend this so that other functions have both compile-time and run-time versions.
>
>What do you think?
>
>James McComb
>
>P.S. Maybe these should change (for consistency):
>
>#pragma() {} // instead of pragma
>#debug() {} // instead of debug
>#version() {} // instead of version
>

Yes, I like this. Easier to both read and write imo. Very intuitive also, for anyone coming from C/C++. Although I cringe a bit every time I see that syntax, due to previous battles with the C preprocessor, I think D can change that mental image.

-Nod-


June 21, 2005
"James McComb" <ned@jamesmccomb.id.au> wrote in message news:d97vjn$20lk$1@digitaldaemon.com...
> What about this? Instead of:
>
> static if() {}
> else
>
> What about:
>
> #if() {} // static if
> #else () {} // static else
>
> If would be easy to write code mixing #if, if, #else and else without confusing them.
>
> Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
>
> #assert() {} // instead of static assert
> #is() {} // instead of iftype, or the 'static' is
>          // (there would be both is and #is)
>
> It would be easy to extend this so that other functions have both compile-time and run-time versions.
>
> What do you think?
>
> James McComb
>
> P.S. Maybe these should change (for consistency):
>
> #pragma() {} // instead of pragma
> #debug() {} // instead of debug
> #version() {} // instead of version

As much as I hate the # symbol, it's a good idea.  It makes compile-time stuff stand out.


June 21, 2005
Jarrett Billingsley wrote:
> "James McComb" <ned@jamesmccomb.id.au> wrote in message news:d97vjn$20lk$1@digitaldaemon.com...
> 
>>What about this? Instead of:
>>
>>static if() {}
>>else
>>
>>What about:
>>
>>#if() {} // static if
>>#else () {} // static else
>>
>>If would be easy to write code mixing #if, if, #else and else without confusing them.
>>
>>Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
>>
>>#assert() {} // instead of static assert
>>#is() {} // instead of iftype, or the 'static' is
>>         // (there would be both is and #is)
>>
>>It would be easy to extend this so that other functions have both compile-time and run-time versions.
>>
>>What do you think?
>>
>>James McComb
>>
>>P.S. Maybe these should change (for consistency):
>>
>>#pragma() {} // instead of pragma
>>#debug() {} // instead of debug
>>#version() {} // instead of version
> 
> 
> As much as I hate the # symbol, it's a good idea.  It makes compile-time stuff stand out. 
> 
> 

I agree.
June 21, 2005
clayasaurus wrote:
>> As much as I hate the # symbol, it's a good idea.  It makes compile-time stuff stand out.
>>
> 
> I agree.


Me too   // like some brain-dead AOL-er



-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
June 22, 2005
James McComb wrote:
> What about this? Instead of:
> 
> static if() {}
> else
> 
> What about:
> 
> #if() {} // static if
> #else () {} // static else
> 
> If would be easy to write code mixing #if, if, #else and else without confusing them.
> 
> Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
> 
> #assert() {} // instead of static assert
> #is() {} // instead of iftype, or the 'static' is
>          // (there would be both is and #is)
> 
> It would be easy to extend this so that other functions have both compile-time and run-time versions.
> 
> What do you think?
> 
> James McComb
> 
> P.S. Maybe these should change (for consistency):
> 
> #pragma() {} // instead of pragma
> #debug() {} // instead of debug
> #version() {} // instead of version
> 
> 
I had similar idea about this. As long as we already have #line

Interesting how many positive posts must be in this thread to have this change implemented by Walter?
June 22, 2005
Personally, I don't like this.  Specifically because the minute this changes, people will start:

  - complaining about #if enforcing scope.  C/C++ didn't require this, they'll say.
  - aligning things to the far left like with a preprocessor, which is ugily.  I thought that was part of why D had these things in the language.
  - asking for things like #ifdef instead of #version, and no parenthesis or curly braces.

Why?  Because you make it look like the preprocessor if you make this change.  You also make it such that, in some cases, (where things are aligned left already) you cannot use a preprocessor correctly - unless you change everything:

#version = test;
#version(test)
#{
#}

Which still leaves:

const int x = 5;
#if (x == 5)  // <-- error, preprocessor doesn't know about x!

Etcetera.  It just separates it from the language, doesn't it?  Even if it still is part of the compiler.

-[Unknown]


> What about this? Instead of:
> 
> static if() {}
> else
> 
> What about:
> 
> #if() {} // static if
> #else () {} // static else
> 
> If would be easy to write code mixing #if, if, #else and else without confusing them.
> 
> Other 'static functions' that evaluate compile-time expressions could use this pragma-style syntax, e.g:
> 
> #assert() {} // instead of static assert
> #is() {} // instead of iftype, or the 'static' is
>          // (there would be both is and #is)
> 
> It would be easy to extend this so that other functions have both compile-time and run-time versions.
> 
> What do you think?
> 
> James McComb
> 
> P.S. Maybe these should change (for consistency):
> 
> #pragma() {} // instead of pragma
> #debug() {} // instead of debug
> #version() {} // instead of version
> 
> 
> 
> 
> 
> 
June 22, 2005
In article <d99ilo$gag$1@digitaldaemon.com>, Tom S says...
>
>clayasaurus wrote:
>>> As much as I hate the # symbol, it's a good idea.  It makes compile-time stuff stand out.
>>>
>> 
>> I agree.
>
>
>Me too   // like some brain-dead AOL-er
>

You're about as useless as JPEGs to Helen Keller.

>
>-- 
>Tomasz Stachowiak  /+ a.k.a. h3r3tic +/

Regards,
James Dunne
« First   ‹ Prev
1 2 3 4