Menu

#5 Number support is not compatible with Java

open
nobody
None
5
2004-09-08
2004-09-08
No

Currently we only support integers in MillScript. This did
not present a problem until our database started using
bigint/numeric ids. These types are are mapped to Java
Long/BigDecimal types.

When we refer to a number in MillScript a Java Integer
object is created to represent it. Now to exemplify the
problem we might need to find all database records with
a particular id(which is a bigint or numeric type). We
query the database as normal, but when we write code
like:

for record in results do
if record[ "id" ] = 3 then
# do something
endif
endfor

we would find that nothing gets done, even if there are
records with an id of 3. This is because the id in the
database record would be represented as a Long,
BigDecimal or even a String holding a representation of
the number(!) while the 3 is represented as an Integer
object. Unfortunately in Java the Integer( 3 ) is NOT
equal to the Long( 3 ).

There are no apparent easy solutions to this problem, as
we are able to access external Java code, hence we
will always have Java numbers floating around. From the
MillScript perspective implementing our own number
system would make sense, as we can eliminate the
problems inherent in the Java ones. It would also give us
the opportunity to integrate rational number support with
mathematical integer(Java Integer + Long) support.

Potentially we could add support for irrational numbers
and dimensions. Irrational numbers are not a high priority
as I can't think of an instance where we have used them.
Dimensions are a higher priority, particularly from a PDF
point of view, where we frequently have to calculate the
size of objects on a page, e.g.

218mm - ( numberOfLines * 10pt )

Discussion


Log in to post a comment.