digitalmars.D - Macros: a visual aid.
- Chris Nicholson-Sauls (20/20) Jul 08 2007 While I'm looking forward to 2.0 macros, I've already noted one thing:
- dennis luehring (2/30) Jul 08 2007 better Foo@()
- Walter Bright (4/7) Jul 08 2007 Part of the intent of macros is to make them look just like functions!
- Kristian Kilpi (9/17) Jul 08 2007 That's right. Well, one option could be allowing macro names to contain
- Walter Bright (3/18) Jul 08 2007 I suggest using the C convention of uppercasing the macro names. Seems
- Chris Nicholson-Sauls (8/17) Jul 08 2007 I'll take your word for it that there's no parser issue. You would
- 0ffh (4/6) Jul 08 2007 I'm not quite sure if D2 will support this, but I suppose you'll be able
- Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= (3/29) Jul 08 2007 I had an impression that one should be able to (more or less) transparen...
- mwarning (2/2) Jul 08 2007 macro is a keyword, so it's highlighted in most D supporting editors.
- Deewiant (6/8) Jul 08 2007 You can't tell the difference at the call site.
- Bent Rasmussen (5/13) Jul 09 2007 I really don't want to tell the difference there. Although it may be
- 0ffh (6/8) Jul 08 2007 I think it was more about recognising the /invocation/ of the macro,
- Walter Bright (3/4) Jul 08 2007 I'm going to steal that witticism! Thanks for the chuckle with my
-
BCS
(2/9)
Jul 08 2007
MORNING coffee!?!?! You posted that after NOON!
- 0ffh (3/8) Jul 09 2007 Welcome! It is so good to be appreciated! :)
- Bent Rasmussen (3/7) Jul 09 2007 Put it in the spec. ;-)
- janderson (7/35) Jul 08 2007 I like the fact that they look exactly like normal functions. It means
- Bill Baxter (7/46) Jul 08 2007 I like 'em to look like normal functions too.
While I'm looking forward to 2.0 macros, I've already noted one thing: they look an awful lot like a CTF call. Given: macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Can you tell a difference? No? Then we're on the same page. :) So I had an idea: why not decorate the macro invocation in some way to make it stand out, such as how template instantiation uses '!()' rather than '()'. I don't think re-using '!()' would be a good idea at all, so I pondered alternatives and arrived at something that might be familiar to some... the ' ' sign. macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to. -- Chris Nicholson-Sauls
Jul 08 2007
Chris Nicholson-Sauls schrieb:While I'm looking forward to 2.0 macros, I've already noted one thing: they look an awful lot like a CTF call. Given: macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Can you tell a difference? No? Then we're on the same page. :) So I had an idea: why not decorate the macro invocation in some way to make it stand out, such as how template instantiation uses '!()' rather than '()'. I don't think re-using '!()' would be a good idea at all, so I pondered alternatives and arrived at something that might be familiar to some... the ' ' sign. macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to. -- Chris Nicholson-Saulsbetter Foo ()
Jul 08 2007
Chris Nicholson-Sauls wrote:Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to.Part of the intent of macros is to make them look just like functions! (There also isn't any parsing issue, like there is for template invocations.)
Jul 08 2007
On Sun, 08 Jul 2007 10:35:49 +0300, Walter Bright <newshound1 digitalmars.com> wrote:Chris Nicholson-Sauls wrote:That's right. Well, one option could be allowing macro names to contain some special char(s)? E.g. macro foo() {} macro bar () {} foo(); bar ();Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to.Part of the intent of macros is to make them look just like functions! (There also isn't any parsing issue, like there is for template invocations.)
Jul 08 2007
Kristian Kilpi wrote:On Sun, 08 Jul 2007 10:35:49 +0300, Walter BrightI suggest using the C convention of uppercasing the macro names. Seems to work fine.Part of the intent of macros is to make them look just like functions! (There also isn't any parsing issue, like there is for template invocations.)That's right. Well, one option could be allowing macro names to contain some special char(s)? E.g. macro foo() {} macro bar () {} foo(); bar ();
Jul 08 2007
Walter Bright wrote:Chris Nicholson-Sauls wrote:I'll take your word for it that there's no parser issue. You would know, after all. But... while I'm clearly an odd stand-out minority, I really just feel uncomfortable with macros as function look-alikes. I guess i'll just have to adopt some naming scheme to suffice... but that leaves me powerless if using a library's macros. Alas. -- Chris Nicholson-SaulsNow that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to.Part of the intent of macros is to make them look just like functions! (There also isn't any parsing issue, like there is for template invocations.)
Jul 08 2007
Chris Nicholson-Sauls wrote:guess i'll just have to adopt some naming scheme to suffice... but that leaves me powerless if using a library's macros.I'm not quite sure if D2 will support this, but I suppose you'll be able to alias foreign macros with names that fit your personal gusto... :) Regards, Frank
Jul 08 2007
Chris Nicholson-Sauls wrote:While I'm looking forward to 2.0 macros, I've already noted one thing: they look an awful lot like a CTF call. Given: macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Can you tell a difference? No? Then we're on the same page. :) So I had an idea: why not decorate the macro invocation in some way to make it stand out, such as how template instantiation uses '!()' rather than '()'. I don't think re-using '!()' would be a good idea at all, so I pondered alternatives and arrived at something that might be familiar to some... the ' ' sign. macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to.I had an impression that one should be able to (more or less) transparently replace many builtin constructs like 'foreach' with macros eventually.
Jul 08 2007
macro is a keyword, so it's highlighted in most D supporting editors. That should tell the eyes the difference even faster then a special char.
Jul 08 2007
mwarning wrote:macro is a keyword, so it's highlighted in most D supporting editors. That should tell the eyes the difference even faster then a special char.You can't tell the difference at the call site. foo(); Is the above a macro or a function? -- Remove ".doesnotlike.spam" from the mail address.
Jul 08 2007
I really don't want to tell the difference there. Although it may be necessary to know at times. This problem falls under the domain of intelligent environments. "Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message news:f6qduv$12pn$1 digitalmars.com...mwarning wrote:macro is a keyword, so it's highlighted in most D supporting editors. That should tell the eyes the difference even faster then a special char.You can't tell the difference at the call site. foo(); Is the above a macro or a function? -- Remove ".doesnotlike.spam" from the mail address.
Jul 09 2007
mwarning wrote:macro is a keyword, so it's highlighted in most D supporting editors. That should tell the eyes the difference even faster then a special char.I think it was more about recognising the /invocation/ of the macro, not the definition: You see something that looks like a function call in a source file, later find it was a macro invocation. As for myself, I like my macros without a syntactic mark of cain. :) Regards, Frank
Jul 08 2007
0ffh wrote:As for myself, I like my macros without a syntactic mark of cain. :)I'm going to steal that witticism! Thanks for the chuckle with my morning coffee.
Jul 08 2007
Reply to Walter,0ffh wrote:MORNING coffee!?!?! You posted that after NOON! <G>As for myself, I like my macros without a syntactic mark of cain. :)I'm going to steal that witticism! Thanks for the chuckle with my morning coffee.
Jul 08 2007
Walter Bright wrote:0ffh wrote:Welcome! It is so good to be appreciated! :) Regards, FrankAs for myself, I like my macros without a syntactic mark of cain. :)I'm going to steal that witticism! Thanks for the chuckle with my morning coffee.
Jul 09 2007
Put it in the spec. ;-) "Walter Bright" <newshound1 digitalmars.com> wrote in message news:f6rek7$a8g$2 digitalmars.com...0ffh wrote:As for myself, I like my macros without a syntactic mark of cain. :)I'm going to steal that witticism! Thanks for the chuckle with my morning coffee.
Jul 09 2007
Chris Nicholson-Sauls wrote:While I'm looking forward to 2.0 macros, I've already noted one thing: they look an awful lot like a CTF call. Given: macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Can you tell a difference? No? Then we're on the same page. :) So I had an idea: why not decorate the macro invocation in some way to make it stand out, such as how template instantiation uses '!()' rather than '()'. I don't think re-using '!()' would be a good idea at all, so I pondered alternatives and arrived at something that might be familiar to some... the ' ' sign. macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to. -- Chris Nicholson-SaulsI like the fact that they look exactly like normal functions. It means you can change an interface to a function or macro without the user knowing. The only problem here of course is if macros work significantly different from their function counter part that it causes problems. -Joel
Jul 08 2007
janderson wrote:Chris Nicholson-Sauls wrote:I like 'em to look like normal functions too. But I assume taking the address of a macro will fail. So "fptr = &foo;" will work on a function but not a macro. There are probably other way in which they will differ, but that seems to be the biggie to me. --bbWhile I'm looking forward to 2.0 macros, I've already noted one thing: they look an awful lot like a CTF call. Given: macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Can you tell a difference? No? Then we're on the same page. :) So I had an idea: why not decorate the macro invocation in some way to make it stand out, such as how template instantiation uses '!()' rather than '()'. I don't think re-using '!()' would be a good idea at all, so I pondered alternatives and arrived at something that might be familiar to some... the ' ' sign. macro Foo () { ... } char[] Bar () { ... } Foo(); Bar(); Now that stands out! So Walter, please consider some sort of decoration (such as the ' ') for macro invocations. I think it may save some future headaches, /and/ give the parser something to latch on to. -- Chris Nicholson-SaulsI like the fact that they look exactly like normal functions. It means you can change an interface to a function or macro without the user knowing. The only problem here of course is if macros work significantly different from their function counter part that it causes problems. -Joel
Jul 08 2007