login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxMaxSingleInteger revision 4 of 5

1 2 3 4 5
Editor: test1
Time: 2013/03/22 21:58:34 GMT+0
Note:

added:

From test1 Fri Mar 22 21:58:34 +0000 2013
From: test1
Date: Fri, 22 Mar 2013 21:58:34 +0000
Subject: 
Message-ID: <20130322215834+0000@axiom-wiki.newsynthesis.org>

SingleInteger is a low level type.  Attempting to use values above max is a user error.  Such an error may be
detected or may produce "correct" result or may lead to some weird problem seemingly unrelated to the
error.  Basically, using SingleInteger is a promise by the user that values will stay within bounds.
So do not lie to the compiler.

Concerning the results: I guess they are due to different Lisp implementations.  SBCL used here by
default is rather strict in error checking.  AFAIK Clisp does not care, it produces "correct"
results.  With other (unsafe) settings in SBCL or with some other Lisp one can get silent
corruption possibly leading to crash.

The maximum of AxiomIssues? is not really maximal.

spad
)abbrev package MYSINT AxiomIssues
AxiomIssues : Public == Private
  where
    Public == IntegerNumberSystem with
      max : () -> %
      mymax : () -> %
      mymax2 : () -> %
    Private  == SingleInteger add
      mymax() == max() + 1
      mymax2() == mymax() + 1
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3288899422624074701-25px001.spad
      using old system compiler.
   MYSINT abbreviates package AxiomIssues 
------------------------------------------------------------------------
   initializing NRLIB MYSINT for AxiomIssues 
   compiling into NRLIB MYSINT 
   compiling exported mymax : () -> $
Time: 0.03 SEC.
compiling exported mymax2 : () -> $ Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |AxiomIssues| REDEFINED
;;; *** |AxiomIssues| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor AxiomIssues Time: 0.03 seconds
--------------non extending category---------------------- .. AxiomIssues of cat (|Join| (|IntegerNumberSystem|) (CATEGORY |domain| (SIGNATURE |max| ($)) (SIGNATURE |mymax| ($)) (SIGNATURE |mymax2| ($)))) has no (|Logic|) finalizing NRLIB MYSINT Processing AxiomIssues for Browser database: --->-->AxiomIssues(constructor): Not documented!!!! --->-->AxiomIssues((max (%))): Not documented!!!! --->-->AxiomIssues((mymax (%))): Not documented!!!! --->-->AxiomIssues((mymax2 (%))): Not documented!!!! --->-->AxiomIssues(): Missing Description ; compiling file "/var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT.lsp" (written 31 JUL 2013 03:36:53 PM):
; /var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT.fasl written ; compilation finished in 0:00:00.014 ------------------------------------------------------------------------ AxiomIssues is now explicitly exposed in frame initial AxiomIssues will be automatically loaded when needed from /var/aw/var/LatexWiki/MYSINT.NRLIB/MYSINT

fricas
a: AxiomIssues := max()$AxiomIssues

\label{eq1}4611686018427387903(1)
Type: AxiomIssues?
fricas
m: AxiomIssues := mymax()
>> System error: The value 4611686018427387904 is not of type FIXNUM.

On my 32 bit system I get


(1) -> )co aaa.spad</p>
<h2>(1) -> m: AxiomIssues<a class=? := mymax()

(1) - 2147483648 Type: AxiomIssues? (2) -> m2: AxiomIssues? := mymax2()

(2) - 2147483647 Type: AxiomIssues? (3) -> (2^31, 2^32, 2^63, 2^64)

(3) [2147483648,4294967296,9223372036854775808,18446744073709551616]? Type: Tuple PositiveInteger? (4) -> b: AxiomIssues? := 2^63-1

(4) - 1 Type: AxiomIssues? (5) -> c: AxiomIssues? := b+1

(5) 0 Type: AxiomIssues? " title=" (1) -> )co aaa.spad

(1) -> m: AxiomIssues? := mymax()

(1) - 2147483648 Type: AxiomIssues? (2) -> m2: AxiomIssues? := mymax2()

(2) - 2147483647 Type: AxiomIssues? (3) -> (2^31, 2^32, 2^63, 2^64)

(3) [2147483648,4294967296,9223372036854775808,18446744073709551616]? Type: Tuple PositiveInteger? (4) -> b: AxiomIssues? := 2^63-1

(4) - 1 Type: AxiomIssues? (5) -> c: AxiomIssues? := b+1

(5) 0 Type: AxiomIssues? " class="equation" src="images/4793645067067265374-16.0px.png" align="bottom" Style="vertical-align:text-bottom" width="560" height="420"/>

SingleInteger? is a low level type. Attempting to use values above max is a user error. Such an error may be detected or may produce "correct" result or may lead to some weird problem seemingly unrelated to the error. Basically, using SingleInteger? is a promise by the user that values will stay within bounds. So do not lie to the compiler.

Concerning the results: I guess they are due to different Lisp implementations. SBCL used here by default is rather strict in error checking. AFAIK Clisp does not care, it produces "correct" results. With other (unsafe) settings in SBCL or with some other Lisp one can get silent corruption possibly leading to crash.