[m-dev.] context "macros"

Peter Wang novalazy at gmail.com
Mon Mar 31 16:50:23 AEDT 2008


On 2008-03-31, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Wed, 26 Mar 2008, Peter Wang wrote:
>>
>> Here is what a change to the reference manual might look like.
>> Julien said __ wasn't a great idea because it's still used as a module
>> qualifier so we chose $foo or $foo$.  $pred is easier to support than
>> $proc and for most code should be equivalent.
>
> For the record $proc gets a bit hairy with --intermodule-optimization.
>
>> Index: doc/reference_manual.texi
>> ===================================================================
>> RCS file: /home/mercury/mercury1/repository/mercury/doc/reference_manual.texi,v
>> retrieving revision 1.424
>> diff -u -r1.424 reference_manual.texi
>> --- doc/reference_manual.texi	27 Feb 2008 09:46:07 -0000	1.424
>> +++ doc/reference_manual.texi	26 Mar 2008 06:33:27 -0000
>> @@ -294,6 +294,10 @@
>> and then another sequence of decimal digits (the exponent).
>> The fraction part or the exponent (but not both) may be omitted.
>>
>> + at item compiler_defined_literal
>> +A compiler-defined literal consists of a dollar sign (@code{$})
>> +followed by a name.
>
> Can it be a quoted name (currently yes)?  Or is that not intended?

I did intend to allow quoted names, but there's no real need for that
and it makes the lexer more hairy, so let's just say "dollar sign
followed by an unquoted name".

>> @item open_ct
>> A left parenthesis, @samp{(}, that is not preceded by whitespace.
>>
>> @@ -1322,7 +1326,8 @@
>> @subsection Data-functors
>>
>> A data-functor is an integer, a float, a string, a character literal
>> -(any single-character name), a name, or a compound data-term.
>> +(any single-character name), a name, a compiler-defined literal,
>>
>> +or a compound data-term.
>> A compound data-term is a compound term which does not match
>> the form of a special data-term (@pxref{Data-terms}),
>> and whose arguments are data-terms.
>> @@ -1330,6 +1335,33 @@
>> must name a function, predicate, or data constructor declared
>> in the program or in the interface of an imported module.
>>
>> +A compiler-defined literal is one of the following. They will be
>> +replaced by constants reflecting the context in which they appear.
>
> I suggest that all Mercury implementations *must* support some of these
> e.g., $file, $line, $module etc.
>
> but that Mercury implementations are free to support others, e.g.
> $grade for the Melbourne implementation.

Ok.

>> +
>> + at table @asis
>> + at item @samp{$file}
>> +the name of the file (string)
>
> @samp{$file} is a string that gives the name of the file that
> contains the module currently being compiled.  If the name of the
> file cannot be determined then ...
>
> ???

it is replaced by an arbitrary string (e.g. "<standard input>") (?)

>> +
>> + at item @samp{$line}
>> +the line number (integer)
>
> Likewise, if the line number in unavailable, what happens?

it is replaced by zero. (?)

>> +
>> + at item @samp{$module}
>> +the module name (string)
>> +
>> + at item @samp{$pred}
>> +the predicate or function name and arity (string)
>> +
>> + at item @samp{$grade}
>> +the compilation grade (string)
>> +
>> + at item @samp{$date}
>> +the date (string)
>> +
>> + at item @samp{$time}
>> +the time (string)
>
> Maybe these would be better uppercase, $FILE, $LINE, etc ?

Given the definition of unquoted name, they should begin with a
lowercase letter.

Peter

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list