Re: [BLACKBOX] Reading variables from strings

From: Campbell, Robert (SELEX GALILEO, UK) <robert.d.campbell{([at]})nowhere.xy>
Date: Fri, 28 May 2010 09:54:13 +0100

nu.&I8߯4w
z{mʗ{V
z{S}ĝxjǺ>> From: BlackBox [mailto:BLACKBOX{([at]})LISTS.OBERON.CH] On Behalf
>> Of Rex Couture
>> Sent: 27 May 2010 22:02


>> Is there a module for reading numbers from strings?

>> I had a go at tracking this down ... to (System?)Stores.Store.

>>>> Thank you, Robert. That was easy.

>> Rex Couture

Hi

I have a few comments about Module Strings:

1) - As far as I know everything, including Stores & the compiler, ultimately sit
on top of module Strings.

2) - The acceptable formats for integers are documented.

3) - The acceptable formats for reals are NOT documented.

4) - Both StringToReal & StringToInt accept leading white space, despite this being
at variance to the documented format.

5) - Neither accepts trailing white space; they both give an error code. However StringToInt
seems to always return the correct result, StringToReal usually returns an incorrect, but maybe plausible, result.
Maybe it would be better to force the result to be NaN or -INF or something specific.

6) - It would be more friendly to allow trailing white space (or atleast spaces).

7) - StringToReal reads "-0." correctly (good!). It is not the same as "+0.".

8) - An extension I would (controversially ?) like to see is the format for integers (and reals)
to be changed from
  number = ( [ "+" | "-" ] dec | hex ) 0X .
to
  number = ( [ "+" | "-" | "-" ] dec | hex ) 0X .


The code line

 IF ch = "-" THEN

would become

 IF (ch = "-") OR (ch = "-") THEN

in four or five places.

The second minus is the unicode character 2212.
I don't think this is likely to break any existing clients.
This proposal is consistent with the main change in BlackBox 1.6, namely better unicode support.
Using the unicode minus makes for better looking output in most fonts, and causes less confusion
with text setting software looking for hyphens.



Regards

Robert


ps - Long time members of this mailing list will already know that I am rather obsessive about numbers!
SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
nu.&I8߯4w
z{mʗbqb
z{m}ޝxjǺ
z{Ch+bv!~)^{\rtf1\ansi\ansicpg1252\fromtext \deff0{\fonttbl
{\f0\fswiss\fcharset0 Arial;}
{\f1\fmodern Courier New;}
{\f2\fnil\fcharset2 Symbol;}
{\f3\fmodern\fcharset0 Courier New;}}
{\colortbl\red0\green0\blue0;\red0\green0\blue255;}
\uc1\pard\plain\deftab360 \f0\fs20 >> From: BlackBox [mailto:BLACKBOX{([at]})LISTS.OBERON.CH] On Behalf \par
>> Of Rex Couture\par
>> Sent: 27 May 2010 22:02\par
\par
\par
>> Is there a module for reading numbers from strings? \par
\par
>> I had a go at tracking this down ... to (System?)Stores.Store.\par
\par
>>>> Thank you, Robert. That was easy.\par
\par
>> Rex Couture\par
\par
Hi\par
\par
I have a few comments about Module Strings:\par
\par
1) - As far as I know everything, including Stores & the compiler, ultimately sit\par
on top of module Strings.\par
\par
2) - The acceptable formats for integers are documented.\par
\par
3) - The acceptable formats for reals are NOT documented.\par
\par
4) - Both StringToReal & StringToInt accept leading white space, despite this being\par
at variance to the documented format.\par
\par
5) - Neither accepts trailing white space; they both give an error code. However StringToInt \par
seems to always return the correct result, StringToReal usually returns an incorrect, but maybe plausible, result.\par
Maybe it would be better to force the result to be NaN or -INF or something specific.\par
\par
6) - It would be more friendly to allow trailing white space (or atleast spaces).\par
\par
7) - StringToReal reads "-0." correctly (good!). It is not the same as "+0.".\par
\par
8) - An extension I would (controversially ?) like to see is the format for integers (and reals)\par
to be changed from\par
  number = ( [ "+" | "-" ] dec | hex ) 0X .\par
to\par
  number = ( [ "+" | "-" | "\u8722 -" ] dec | hex ) 0X .\par
\par
\par
The code line \par
\par
 IF ch = "-" THEN\par
\par
would become\par
\par
 IF (ch = "-") OR (ch = "\u8722 -") THEN\par
\par
in four or five places.\par
\par
The second minus is the unicode character 2212.\par
I don't think this is likely to break any existing clients.\par
This proposal is consistent with the main change in BlackBox 1.6, namely better unicode support.\par
Using the unicode minus makes for better looking output in most fonts, and causes less confusion\par
with text setting software looking for hyphens.\par
\par
\par
\par
Regards\par
\par
Robert\par
\par
\par
ps - Long time members of this mailing list will already know that I am rather obsessive about numbers!\par
SELEX Galileo Ltd\par
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL\par
A company registered in England & Wales. Company no. 02426132\par
********************************************************************\par
This email and any attachments are confidential to the intended\par
recipient and may also be privileged. If you are not the intended\par
recipient please delete it from your system and notify the sender.\par
You should not copy it or use it for any purpose nor disclose or\par
distribute its contents to any other person.\par
********************************************************************}}nu.&I8߯4w
Received on Fri May 28 2010 - 10:54:13 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:31 UTC