I found the package of FOREIGN string operators not only very useful but also informative--even though I don't know Java I might just be able to learn enough from them to write a simple FOREIGN operator myself!
I was surprised not to find OPERATOR LENGTH ( C CHAR ) RETURNS INTEGER in that package, but I did spot LAST_INDEX_OF and so was easily able to make my own NATIVE (?) implementation of LENGTH:
OPERATOR LENGTH ( C CHAR ) RETURNS INTEGER ; RETURN LAST_INDEX_OF ( C, '' ) ; END OPERATOR ;
which pleased me no end!
Now tell me that LENGTH is defined in some other package, or there's some other reason why I din't need to do that.
Hugh
How about a LENGTH operator?
Re: How about a LENGTH operator?
In versions of Rel prior to 0.3.x, LENGTH was a built-in operator. I forgot to include it in OperatorsChar.d when I released the 0.3.x series.
It will be available in the next update (0.3.13), but for now, here's what it should have been:
Of course, your LENGTH operator is just as good!
It will be available in the next update (0.3.13), but for now, here's what it should have been:
Code: Select all
OPERATOR LENGTH(s CHAR) RETURNS INTEGER Java FOREIGN
return new ValueInteger(s.stringValue().length());
END OPERATOR;