Syntactic sugar poll

Maurice Castro maurice@REDACTED
Tue Jan 15 01:54:22 CET 2002


> 
> 
> 	Hi,
> 
> > constants with many bases. There is no need to extend the language to
> > satisfy these programmers as they are free to pre-process their files
> > to use their prefered convention. (eg. sed 's/0x/16#/g' file in this
> 
> 	So net:ping('mynode@REDACTED') would yield interesting results :)

The trouble with simple examples is that they often overlook inconvenient
complexities in order to maintain brevity. When writing the example I 
was aware of the atom, string and comment deficiencies that would result.
Here are 2 solutions:

1)	The script as provided can be used without change if programmers 
	refrain	from using 0x other than for hexadecimal ... very few 
	programs will fail

2) 	A lex based preprocessor (attached) should handle all the cases
	mentioned which are also valid Erlang programs. Lex was chosen as 
	a compact representation.

The key issue is do you extend a language, increasing maintenance costs,
and education costs for all, when those who have a specific need have 
the option of handling the problem themselves with preprocessing or 
metaprogramming.

	Maurice Castro
-------------- next part --------------
%{
#include <stdio.h>
%}
%x STRING
%x ATOM
%x COMMENT
%%
'		{BEGIN ATOM; ECHO;}
<ATOM>'		{BEGIN INITIAL; ECHO;}
\"		{BEGIN STRING; ECHO;}
<STRING>\"	{BEGIN INITIAL; ECHO;}
%		{BEGIN COMMENT; ECHO;}
<COMMENT>.*$	{BEGIN INITIAL; ECHO;}
<INITIAL>0x	{printf("16#");}
%%

int main(int argc, char *argv[])
{
	++argv, --argc;  /* skip over program name */
	if (argc > 0)
		yyin = fopen(argv[0], "r");
	else
		yyin = stdin;
	yylex();
}


More information about the erlang-questions mailing list