Re: Discussion of interval literal syntax
Michel
On 2013 Jul 20, at 19:03, Michel Hack wrote:
> John Pryce asked:
>> On 2013 Jul 20, at 00:30, Vincent Lefevre wrote:
>>> Requiring that all interval literals start with "[" and end with
>>> the first "]" can help...
>>
>> Straw poll please from those with experience in parsing. Does
>> Vincent's suggestion make it easier to parse interval literals?
>
> It does not matter much in the context of text2interval(), where
> we know that an interval is expected. It would help however in
> an implicit-typing language, and perhaps even more in interpretive
> or just-in-time-compilation settings.
Yes, particularly for a function that reads objects from a file or standard input, and determines on the fly what kind of object it is.
It just strikes me that an important language of that kind is Matlab (and its clones). Unfortunately there is an unavoidable clash: Matlab uses brackets to construct arrays so they are unavailable for intervals. Here is the "input" function being used with in effect dynamic-typing (is that the same as implicit-typing?):
> >> while true, x=input('Give x: '), end
> Give x: 1.23 %scalar
> x = 1.2300
> Give x: [1.2,3.4;5.6,7.8] %2 by 2 array
> x =
>
> 1.2000 3.4000
> 5.6000 7.8000
>
> Give x: {1,2,3,4} %cell vector
> x =
>
> {
> [1,1] = 1
> [1,2] = 2
> [1,3] = 3
> [1,4] = 4
> }
etc.
When a 1788 implementation is built in Matlab, it would be nice to overload "input" so that it can read intervals using text2interval(), but that would need a syntax change! Any ideas?
John Pryce