Erlang Mailing Lists

Author Message

<  Erlang bugs mailing list  ~  Macros and keywords, R9C2

thomasl_erlang at yahoo.c
Posted: Wed Sep 08, 2004 2:08 pm Reply with quote
Guest
You currently can't define macros with the same name
as keywords:

-define(begin, 4711).
-define(end, 11147).

% compiler complains "badly formed define"

However, this restriction is, as far as I can see,
unnecessary: the namespaces are entirely distinct.
That is, when you subsequently use the macro, it will
be written '?begin', which will never be confused with
plain 'begin'.

Hence, I report this as a bug.

Best,
Thomas




__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail


Post generated using Mail2Forum (http://m2f.sourceforge.net)
danie at erlfinsys.net
Posted: Wed Sep 08, 2004 2:23 pm Reply with quote
Guest
I understand the reasoning, but from a practical perspective, isn't it
better to stay away from names like that - just to avoid confusion?
(Especially with newbies)

-------
begin
case ?begin of

vs
case ?BEGIN_PORT of
-------
A bit far fetched though :)



On Wed, 2004-09-08 at 16:08, Thomas Lindgren wrote:
> You currently can't define macros with the same name
> as keywords:
>
> -define(begin, 4711).
> -define(end, 11147).
>
> % compiler complains "badly formed define"
>
> However, this restriction is, as far as I can see,
> unnecessary: the namespaces are entirely distinct.
> That is, when you subsequently use the macro, it will
> be written '?begin', which will never be confused with
> plain 'begin'.
>
> Hence, I report this as a bug.
>
> Best,
> Thomas
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
>



Post generated using Mail2Forum (http://m2f.sourceforge.net)
thomasl_erlang at yahoo.c
Posted: Wed Sep 08, 2004 4:18 pm Reply with quote
Guest
--- Danie Schutte <danie_at_erlfinsys.net> wrote:

> I understand the reasoning, but from a practical
> perspective, isn't it
> better to stay away from names like that - just to
> avoid confusion?
> (Especially with newbies)

Actually, I thought it a bit confusing that one
_couldn't_ define begin, end, etc :-)

Personally, I would consider "[staying] away from
names like that" a matter for organizational coding
standards, rather than language standards. For
instance, you can already use 'begin', 'end' and so on
as atoms. And Erlang macros can already be confusing
for all the usual reasons (just like C macros).

Best,
Thomas

PS. Nice domain name :-)




__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum