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

This is an example of using pretend to perform a type unsafe operation.

The follow commands are run using FriCAS

fricas
)version
Value = "FriCAS 1.2.1 compiled at Monday July 1, 2013 at 23:26:54 "

spad
)abbrev package CAST cast
cast(): exports == implementation where
exports == with
cast1: Integer -> Float
implementation == add
cast1(i:Integer):Float == j:Float := (i pretend Float)
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/76482798552469661-25px002.spad
      using old system compiler.
   CAST abbreviates package cast 
------------------------------------------------------------------------
   initializing NRLIB CAST for cast 
   compiling into NRLIB CAST 
   compiling exported cast1 : Integer -> Float
      CAST;cast1;IF;1 is replaced by LETji 
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |cast| REDEFINED
;;; *** |cast| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor cast Time: 0 seconds
finalizing NRLIB CAST Processing cast for Browser database: --->-->cast(constructor): Not documented!!!! --->-->cast((cast1 ((Float) (Integer)))): Not documented!!!! --->-->cast(): Missing Description ; compiling file "/var/aw/var/LatexWiki/CAST.NRLIB/CAST.lsp" (written 14 JUL 2013 10:42:54 AM):
; /var/aw/var/LatexWiki/CAST.NRLIB/CAST.fasl written ; compilation finished in 0:00:00.011 ------------------------------------------------------------------------ cast is now explicitly exposed in frame initial cast will be automatically loaded when needed from /var/aw/var/LatexWiki/CAST.NRLIB/CAST

This command used to cause a "memory may be damaged" error::

fricas
cast1(1)$CAST
>> System error: The value 1 is not of type CONS.

aldor
#include "axiom"
cast2(i: Integer): Float == {
      j:Float := (i pretend Float)
}
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/casta.as 
      using AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/casta.as", line 2: cast2(i: Integer): Float == { ......^..^.........^ [L2 C7] #11 (Error) There are no suitable meanings for the operator `->'. [L2 C10] #9 (Error) No meaning for identifier `Integer'. [L2 C20] #10 (Error) No meaning for identifier `Float'. [L2 C20] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

This command also used cause a "memory may be damaged" error::

fricas
cast2(1)
There are no library operations named cast2 Use HyperDoc Browse or issue )what op cast2 to learn if there is any operation containing " cast2 " in its name.
Cannot find a definition or applicable library operation named cast2 with argument type(s) PositiveInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: