POV-Ray : Newsgroups : povray.advanced-users : Allowing reserved keywords to be used as identifier names? : Re: Allowing reserved keywords to be used as identifier names? Server Time
28 Jul 2024 18:21:38 EDT (-0400)
  Re: Allowing reserved keywords to be used as identifier names?  
From: Leonardo
Date: 31 May 2004 16:15:01
Message: <web.40bb918792c0db7127bbadf50@news.povray.org>
>   The parser could use intelligent heuristics to decide which interpretation
> is correct.
>   The simplest heuristic would be: "This is the name of a keyword. If
> I use it as a keyword in this place, will it cause a syntax error? If
> yes, use it as a keyword, else use it as an identifier name." That is,
> the name of a keyword is always used as a keyword if possible (ie. it
> doesn't cause an error), and only if it won't work as a keyword it will
> be tested as an identifier.

Those parser decisions can mislead the programmer to errors, because the
rules for an identifier to be upgraded to keyword depends on the context.
Context-sensitive grammars are not generally adopted in programming
languages.

>
>   Another possibility is to issue an error message about the ambiguous use
> of the name in that place.
That would be better.

>   Sometimes this is not possible. For example "size" is a good variable
> name and a good keyword name. The same applies to many other examples,
> such as "radius", "location", "angle", etc.
As I said this is a problem with POVRay's SDL

>   This would make writing SDL more complicated. I'm not really sure I like
> that.
Maybe... but this way, the language can be extended in the future without
conflicts. And maybe provide some plug-in API for anyone to add new
functionality. But thats is another topic... :)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.