Frank Heckenbach wrote:
Gale Paeper wrote:
Thanks for the speedy fix. Without trying the patch yet, I think the other changes might also be needed. When I tried changing the code to a run-time expression evaluation instead of a compile-time constant-expression evaluation to avoid the internal compiler error, I got an error message which in effect said the result of substr((s),1,1) wasn't a ordinal type and therefore the useage of substr((s),1,1) as an argument for the ord function was illegal. Changing it to:
ord(substr((s),1,1)[1])
did make the "not an ordinal type" problem go away. So, those trying to use the macro along with the patch may need to supplement the macro with string array indexing.
This makes me wonder if this should be allowed at all (including parts of the previous change):
To clarify, you are questioning the legality of just ord(substr((s),1,1))?
If so, after posting my original internal compiler error message, it dawned on me that perhaps I was pushing the type compatibility rules too far and that the error was due to stressing the compiler with possibly an illegal construct which it was unable to deal with. Therefore, to remove uncetainties about char-type string-type type compatibilities and the ord function, I tried the array indexed form for the constant-expression but, unfortunately, that form also resulted in an internal compiler error. This prompted the run-time expression investigation and the above reported results.
Given the mixture of error results, I was in the process of determining exactly what should be legal according to standard requirements when I saw the fix patch posting which in essense said problem solved so I didn't pursue the legality question any further.
: substr(s, i, j) : : From the expression s that shall be of chartype or a stringtype and from : the expressions i and j that shall be of integertype, this function shall : return a result of the canonicalstringtype.
: ord(x) : : From the expression x that shall be of an ordinaltype, [...]
I think "expression" is the key for sorting out what is legal since that rules out using the compatible types and assignment compatibility rules which provides for compatibility of char-type and string-types in parameters.
And the canonicalstringtype, even values of length 1, is not an ordinaltype, AFAIK. I find this:
: Each stringtype value is a : value of the canonicalstringtype.
: NOTE --- 3 Chartype values possess properties that allow them to be : used identically to stringtype values of length 1. In particular,
but not vice verse.
Am I missing something?
I don't think you are. Since the ord argument requirement is specified with expression and not parameter terms and the expression "substr((s),1,1)" is of type canonicalstringtype which isn't an ordinal-type, "substr((s),1,1)" is an illegal argument for ord since it doesn't satisfy the ordinal-type expression requirement. ("substr((s),1,1)[1]" is legal since the individual components of string-types are char-types which is an ordinal-type and thus the expression is of ordinal-type.)
You're still left with two constant-expression internal compiler errors which need to be fixed.
1. For constant-expression ord(substr((s),1,1)), detecting that it isn't an ordinal expression and issuing an appropriate error message.
2. For constant-expression ord(substr((s),1,1)[1]), evaluating the expression with a result of the ordinal-value of the first character in the constant-string "s".
Gale Paeper gpaeper@empirenet.com