PrintLn and long numbers

1 view
Skip to first unread message

Akshaal

unread,
Jul 20, 2008, 12:38:45 PM7/20/08
to termware
Termware is a very good framework for high level computations. But
there is a room to grow. Is there ongoing work to remove
System.out.println from the sources and add a support for long number
values?

For example,

TermSystem termSystem =
new TermSystem (new FirstTopStrategy (),
new DefaultFacts (),
TermWare.createNewInstance ());

termSystem.addRule ("A -> B [test(1216568340864)]");

will get you exception (see below) on the screen only and behavior as
if you have given it ""A -> B [test(0)]"".

Number format exception:java.lang.NumberFormatException: For input
string: "1216568340864"

ruslan.s....@gmail.com

unread,
Jul 21, 2008, 1:54:24 PM7/21/08
to termware


On Jul 20, 7:38 pm, Akshaal <l...@toril.ru> wrote:
> Termware is a very good framework for high level computations. But
> there is a room to grow. Is there ongoing work to remove
> System.out.println from the sources and add a support for long number
> values?
>

1. We have no System.out.println in sources
//instead we passing env object, which user can substitute to own.

So, to redirect outpot to own logger, write class which implements
IEnv (http://www.gradsoft.ua/rus/Products/termware/jdocs/ua/gradsoft/
termware/IEnv.html)
and set one as output to system, like

IEnv emyEnv = new MyEnv();
termSyste.setEmv(myEnv);

// If somewhere exists System.out() - than this is packaging error.
Tell me and I will repackage next minor release immediatly

> For example,
>
> TermSystem termSystem =
>             new TermSystem (new FirstTopStrategy (),
>                             new DefaultFacts (),
>                             TermWare.createNewInstance ());
>
> termSystem.addRule ("A -> B [test(1216568340864)]");
>
> will get you exception (see below) on the screen only and behavior as
> if you have given it ""A -> B [test(0)]"".
>
> Number format exception:java.lang.NumberFormatException: For input
> string: "1216568340864"


Hmm -- good idea ;)

I think we will include some syntax for inline big numbers in next
release
(now we support ones internally)

Note, that now you can pass big numbers to terms from java .

ruslan.s....@gmail.com

unread,
Jul 21, 2008, 2:02:58 PM7/21/08
to termware


On Jul 20, 7:38 pm, Akshaal <l...@toril.ru> wrote:
> Termware is a very good framework for high level computations. But
> there is a room to grow. Is there ongoing work to remove
> System.out.println from the sources and add a support for long number
> values?
>

1. We have no System.out.println in sources, instead we pass to
system callback interface IEnv,
which incapsulate all output.
I.e. to handle output by own methods, you must
a) create class IEnv whith own implementation of getOutput(),
getLog() and show()
b) pass own env to system with help of TermSystem.setEnv method

i.e. code will look like
IEnv myEnv = new MyEnv();
termSystem.setEnv(myEnv);


> For example,
>
> TermSystem termSystem =
>             new TermSystem (new FirstTopStrategy (),
>                             new DefaultFacts (),
>                             TermWare.createNewInstance ());
>
> termSystem.addRule ("A -> B [test(1216568340864)]");
>
> will get you exception (see below) on the screen only and behavior as
> if you have given it ""A -> B [test(0)]"".
>
> Number format exception:java.lang.NumberFormatException: For input
> string: "1216568340864"

About handling big numbers in text -- goog idea.

for now we support big integers internally, i.e.
Term term = termFactory.createBigInteger(bi);
will work.

I think in shortcoming release we will propose some syntax for
handling big integers in strings.

Evgeny Chukreev

unread,
Jul 21, 2008, 2:20:47 PM7/21/08
to term...@googlegroups.com, ruslan.s....@gmail.com
On Mon, 21 Jul 2008 11:02:58 -0700 (PDT)
<ruslan.s....@gmail.com> wrote me:

> On Jul 20, 7:38 pm, Akshaal <l...@toril.ru> wrote:

>> Termware is a very good framework for high level computations. But
>> there is a room to grow. Is there ongoing work to remove
>> System.out.println from the sources and add a support for long number
>> values?
>>

> 1. We have no System.out.println in sources, instead we pass to
> system callback interface IEnv,
> which incapsulate all output.
> I.e. to handle output by own methods, you must
> a) create class IEnv whith own implementation of getOutput(),
> getLog() and show()
> b) pass own env to system with help of TermSystem.setEnv method

> i.e. code will look like
> IEnv myEnv = new MyEnv();
> termSystem.setEnv(myEnv);

Sorry, it were not System.out.println, but System.err.println, like
System.err.println("Number format exception:"+ex.toString());
in TermWare1.jj

It would be nice to have such lines migrated to use IEnv for exception
handling (not just printing of error message, but handling as well, so one
could stop parsing).

>> For example,
>>
>> TermSystem termSystem =
>>             new TermSystem (new FirstTopStrategy (),
>>                             new DefaultFacts (),
>>                             TermWare.createNewInstance ());
>>
>> termSystem.addRule ("A -> B [test(1216568340864)]");
>>
>> will get you exception (see below) on the screen only and behavior as
>> if you have given it ""A -> B [test(0)]"".
>>
>> Number format exception:java.lang.NumberFormatException: For input
>> string: "1216568340864"

> About handling big numbers in text -- goog idea.

> for now we support big integers internally, i.e.
> Term term = termFactory.createBigInteger(bi);
> will work.

> I think in shortcoming release we will propose some syntax for
> handling big integers in strings.

I suppose 1216568340864L (pay attention to L suffix) is natural enough for
Long value.

--
... WBR, Evgeny Chukreev ...

ruslan.s....@gmail.com

unread,
Jul 22, 2008, 10:41:31 AM7/22/08
to termware
>
> > 1.  We have no System.out.println in sources, instead we pass to
> > system callback interface IEnv,
> > which incapsulate all output.
> > I.e. to handle output by own methods, you must
> > a)  create class IEnv whith own implementation of getOutput(),
> > getLog() and show()
> > b)  pass own env to system with help of TermSystem.setEnv method
> > i.e. code will look like
> > IEnv myEnv = new MyEnv();
> > termSystem.setEnv(myEnv);
>
> Sorry, it were not System.out.println, but System.err.println, like
> System.err.println("Number format exception:"+ex.toString());
> in TermWare1.jj
>

Thanks - will be fionxed in 2.3.1


> It would be nice to have such lines migrated to use IEnv for exception
> handling (not just printing of error message, but handling as well, so one
> could stop parsing).
>
>
>
> >> For example,
>
> >> TermSystem termSystem =
> >>             new TermSystem (new FirstTopStrategy (),
> >>                             new DefaultFacts (),
> >>                             TermWare.createNewInstance ());
>
> >> termSystem.addRule ("A -> B [test(1216568340864)]");
>
> >> will get you exception (see below) on the screen only and behavior as
> >> if you have given it ""A -> B [test(0)]"".
>
> >> Number format exception:java.lang.NumberFormatException: For input
> >> string: "1216568340864"
> > About handling big numbers in text -- goog idea.
> > for now we support big integers internally, i.e.
> > Term term = termFactory.createBigInteger(bi);
> > will work.
> > I think in shortcoming release we will propose some syntax for
> > handling big integers in strings.
>
> I suppose 1216568340864L (pay attention to L suffix) is natural enough for
> Long value.
>

Yes. Will be implemented in next release.
(Note, that if you don't want to wait, than changes to TermWare1.jj
for this will be near trivial and we accept patches ;) )
Reply all
Reply to author
Forward
0 new messages