Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Fw: Motion 31 Suggestions - constants



VL> How about something like 1_to_2.5_interval to express [1,2.5]
VL> for instance?


I'll have to check the final wording in the standard to see if a User Defined Literal conversion operator could accept literal syntax like 1_to_2.5_interval. A literal has to either start with a digit or be in quotes, and obviously it has to end with the specified suffix. A separate new feature allows "_" in numeric literals. The problematic part is the "to". 1___2.5_interval should be OK. The quoted literal "1_to_2.5"interval should be OK.


IM>> ... The constant is not a function, but the conversion from
IM>> its external form to its internal form is defined by a function.  It is
IM>> internally represented the same way a variable is and generally treated the
IM>> same way a variable is, except that it is not allowed to be changed.  Maybe
IM>> 1788 could use that approach, instead of defining constants as functions?

VL> The way I see the P1788 text is that constants are regarded as
VL> functions for the spec, but it is up to the language to decide
VL> how they are handled.

Yes, 1788 can defined constants as functions and languages can define them as not functions.

I spend my time dealing with programs, programming languages and their implementation, not with mathematics. I find treating constants as functions counterintuitive and think it introduces unneeded complexity to the standard, since every place it mentions functions we have to think about whether that part of the wording is exactly correct for constants. For example, while an implementation can have a library that includes all non-constant functions defined by the standard, it cannot realistically have a library that includes all 2^128-1 constants (assuming binary128). It makes more sense to me to treat constants differently from functions. We do in real life.

Here's how I'd define it:
Interval "operations" and "functions" deal with (consume and/or produce) interval "values". Some values are calculated; others are "constants". Some constants are "named constants" which represent specific interval values (eg, Entire defined by 1788 represents [-oo,+oo]); others are numeric and are converted from text to interval values by "constant conversion functions". Both named constants and constant conversion functions may be defined by 1788 and/or programming languages/environments/applications and/or users. The 1788 constraints on constant (and other) conversion functions are that (1) they must either produce a valid interval or in some way report an error and (2) they must not violate containment of the value represented by a reasonable interpretation of the text.

I hope we don't have to define a "reasonable interpretation of the text" in the standard. If you like the semantics, I expect you can significantly improve my wording.

- Ian McIntosh IBM Canada Lab Compiler Back End Support and Development


Inactive hide details for Vincent Lefevre ---01/26/2012 07:49:08 AM---On 2012-01-24 16:51:29 -0500, Ian McIntosh wrote: > I desVincent Lefevre ---01/26/2012 07:49:08 AM---On 2012-01-24 16:51:29 -0500, Ian McIntosh wrote: > I designed that (and others improved my design)


From:

Vincent Lefevre <vincent@xxxxxxxxxx>

To:

Ian McIntosh/Toronto/IBM@IBMCA

Date:

01/26/2012 07:49 AM

Subject:

Re: Fw: Motion 31 Suggestions





On 2012-01-24 16:51:29 -0500, Ian McIntosh wrote:
> I designed that (and others improved my design) before 1788, so it wasn't
> designed for intervals, but there are several ways it could be used for
> them.  The brackets are an problem.  One solution would be to require
> quoting, eg, "[1,  2.5]"interval.  If the Interval class conversion
> operator allowed it, you could write syntax like "[0, oo)"interval.  The
> class author or any user could of course define the name Entire to be the
> constant "[-oo,  +oo]"interval.  The interval for a floating point value
> could potentially be written 12_interval or 12.345_interval, which would be
> converted into the singleton [12, 12] and the non-singleton [12.345 rounded
> down, 12.345 rounded up].

How about something like 1_to_2.5_interval to express [1,2.5]
for instance?

> User defined literals define a function (or functions) to convert some
> sequence of characters in a program that meet some defined syntax
> representing a literal into the corresponding internal constant of the
> specified type.  The constant is not a function, but the conversion from
> its external form to its internal form is defined by a function.  It is
> internally represented the same way a variable is and generally treated the
> same way a variable is, except that it is not allowed to be changed.  Maybe
> 1788 could use that approach, instead of defining constants as functions?

The way I see the P1788 text is that constants are regarded as
functions for the spec, but it is up to the language to decide
how they are handled.

--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <
http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <
http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)