Calling Lisp from SPAD

Lisp is the underlying runtime environment and SPAD relies on direct calls to Lisp to provide basic functionality. The names of these function calls end with $Lisp.

I am searching through the FriCAS library code to find what Lisp functions are called from SPAD code.

As Waldek Hebisch explains here the $Lisp calls are of 3 types

If you look at top users of '$Lisp' calls you will see:

Most of them wrap Lisp functionality and make it available as Spad functions. For example in sf.spad we have

x + y == add_DF(x, y)$Lisp

This effectively tells Spad compiler how to add machine floats. _All_ other places in algebra which want to add machine floats should use '+' from DoubleFloat instead of calling underlying Lisp operation. Operation like this form largest and most important group, basically anything we do with integers, machine floats, booleans, stings, lists will end up being performed as one or more Lisp operations. So all primitive operations are taken from Lisp and other are written in terms of primitives (via Spad wrappers). Normally you should have no need to directly use Lisp primitives, because you can get the same effect from Spad operations. Of course, you need Lisp primitives when you want to add new basic type, but then you need _new_ primitives specially written for your new type.

Other group of operations are ones which form system interface. Such operations form bulk of '$Lisp' calls in 'files.spad'.

Next, there are calls to interpreter functions. Those are candidates for replacements by Spad code. In principle user may want to call them. Note however that functions which looked useful are typically exposed via Spad interface. Also, technically it is possible to call from Spad arbitrary interpreter function and there is no reason to think that functions already called are more likely to be called than other. So when you think about documenting such calls for possible uses, you really have task of documenting interpreter functions.

These are my results so far:

Lisp Functions

Here are some Lisp functions which can be called from SPAD

lisp function Called from Pamphlet information
sayTeX$Lisp "hello"  

Description

 

mathObject2String$Lisp  

Description

 

ATOM(expr)$Lisp  

Description

break down an expression into atoms

trapNumericErrors(ff)$Lisp  

Description

 

Example

myTrap1(ff:DF-> DF, f:DF):DF ==
s := trapNumericErrors(ff(f))$Lisp :: Union(DF, "failed")

outputTran$Lisp  

Description

COMPLEXP(x)$Lisp  

Description

Test if x is complex number

EQ(a, b)$Lisp

aggcat
any
boolean

Description

tests if parameters are same objects

Signature

(%, %) -> Boolean

Example

eq?(a, b) == EQ(a, b)$Lisp

NIL$Lisp

aggcat2
array2
boolean

Description

 

Example

i := minIndex(w := new(#l, NIL$Lisp)$B)

assignSymbol(x,f,%)$Lisp algfunc

Description

 

Example

assign(x, f) == (assignSymbol(x, f, %)$Lisp; f)

dbName(x)$Lisp alqi

Description

 

Example

name : OutputForm := dbName(x)$Lisp

dbPart(x, 4, x)$Lisp alqi

Description

 

Example

type : OutputForm := dbPart(x, 4, 1$Lisp)$Lisp

1$Lisp

(or other number such as 0)

alqi
array1

Description

 

Example

type : OutputForm := dbPart(x, 4, 1$Lisp)$Lisp

hconcat alqi

Description

 

Example

hconcat(alqlGetOrigin(x$Lisp)$Lisp

x$Lisp

(where x is a string)

alqi

Description

 

Example

x$Lisp

alqlGetParams(par)$Lisp alqi

Description

 

Example

alqlGetParams(x$Lisp)$Lisp

SUBSTRING(part, 0, 1)$Lisp alqi

Description

 

Example

String := SUBSTRING(dbPart(x, 3, 1)$Lisp, 0, 1)$Lisp

PNAME(sel)$Lisp alqi

Description

 

Example

PNAME(sel)$Lisp

alqlGetKindString(x)$Lisp alqi

Description

 

Example

s = "kind" => alqlGetKindString(x)$Lisp

alqlGetOrigin(x)$Lisp alqi

Description

 

Example

s = "origin" => alqlGetOrigin(x)$Lisp

alqlGetParams(x)$Lisp alqi

Description

 

Example

s = "params" => alqlGetParams(x)$Lisp

dbComments(x)$Lisp alqi

Description

 

Example

s = "doc" => dbComments(x)$Lisp

stringMatches?(val, x.field)$Lisp alqi

Description

 

Example

stringMatches?(val, x.field)$Lisp

getBrowseDatabase(s)$Lisp alqi

Description

 

Example

getDatabase(s) == getBrowseDatabase(s)$Lisp

QSMULMOD32$Lisp amodgcd

Description

 

Example

Qmul ==> QSMULMOD32$Lisp

QSMULADDMOD64_-32$Lisp amodgcd

Description

 

Example

Qmuladd ==> QSMULADDMOD64_-32$Lisp

SETF$Lisp amodgcd

Description

 

Example

(SETF$Lisp)(xr, xr) pretend MP

evalType(dx)$Lisp any

Description

 

Example

Dx : Type := evalType(dx)$Lisp

spad2BootCoerce(x.ob, x.dm,
list)$Lisp
any

Description

 

Example

spad2BootCoerce(x.ob, x.dm,
list('OutputForm)$List(Symbol))$Lisp

prefix2String(dev)$Lisp any

Description

 

Example

p : Symbol := prefix2String(devaluate(x.dm)$Lisp)$Lisp

devaluate(x.dm)$Lisp any

Description

 

Example

p : Symbol := prefix2String(devaluate(x.dm)$Lisp)$Lisp

isValidType(domain)$Lisp any

Description

 

Example

(isValidType(domain)$Lisp)@Boolean



QVMAXINDEX$Lisp


array1

Description

 

Example

Qmax ==> QVMAXINDEX$Lisp

QVSIZE$Lisp array1

Description

 

Example

Qsize ==> QVSIZE$Lisp

QAREF1$Lisp array1

Description

 

Example

Qelt ==> QAREF1$Lisp

QSETAREF1$Lisp array1

Description

 

Example

Qsetelt ==> QSETAREF1$Lisp

MAKE_-ARRAY$Lisp array1

Description

 

Example

Qnew ==> MAKE_-ARRAY$Lisp

MAKEARR1$Lisp array1

Description

 

Example

Qnew1 ==> MAKEARR1$Lisp

less_SI(i, num)$Lisp array1

Description

 

Example

less_SI(i, 1$Lisp)$Lisp

QAREF1O$Lisp
array1

Description

 

Example

Qelt1 ==> QAREF1O$Lisp

QSETAREF1O$Lisp array1

Description

 

Example

QSETAREF1O$Lisp

MATRIX_SIZE$Lisp array2

Description

 

Example

Qsize ==> MATRIX_SIZE$Lisp

MAKE_MATRIX$Lisp
array2

Description

 

Example

Qnew ==> MAKE_MATRIX$Lisp

MAKE_MATRIX1$Lisp array2

Description

 

Example

Qnew1 ==> MAKE_MATRIX1$Lisp

ANROWS$Lisp
array2

Description

 

Example

Qnrows ==> ANROWS$Lisp

ANCOLS$Lisp
array2

Description

 

Example

Qncols ==> ANCOLS$Lisp

QAREF2O$Lisp array2

Description

 

Example

Qelt2 ==> QAREF2O$Lisp

QSETAREF2O$Lisp array2

Description

 

Example

Qsetelt2 ==> QSETAREF2O$Lisp

LAST$Lisp bags

Description

 

Example

lastTail==> LAST$Lisp

NOT(b)$Lisp boolean

Description

 

Example

not b == NOT(b)$Lisp

AND(a, b)$Lisp boolean

Description

 

Example

_/_\(a, b) == AND(a, b)$Lisp

OR(a, b)$Lisp boolean

Description

 

Example

_\_/(a, b) == OR(a, b)$Lisp

BooleanEquality(a, b)$Lisp boolean

Description

 

Example

a = b == BooleanEquality(a, b)$Lisp

bool_to_bit(b)$Lisp boolean

Description

 

Example

new(n, b) == make_BVEC(n, bool_to_bit(b)$Lisp)$Lisp

make_BVEC(n,bool)$Lisp boolean

Description

 

Example

new(n, b) == make_BVEC(n, bool_to_bit(b)$Lisp)$Lisp

copy_BVEC(v)$Lisp boolean

Description

 

Example

copy v == copy_BVEC(v)$Lisp

size_BVEC(v)$Lisp boolean

Description

 

Example

#v == size_BVEC(v)$Lisp

equal_BVEC(v, u)$Lisp boolean

Description

 

Example

v = u == equal_BVEC(v, u)$Lisp

and_BVEC(v, u)$Lisp boolean

Description

 

Example

and_BVEC(v, u)$Lisp

or_BVEC(v, u)$Lisp boolean

Description

 

Example

or_BVEC(v, u)$Lisp

xor_BVEC(v, u)$Lisp boolean

Description

 

Example

xor_BVEC(v, u)$Lisp

SETELT_BVEC(v, range, bit)$Lisp boolean

Description

 

Example

SETELT_BVEC(v, range(v, i - mn), bool_to_bit(f)$Lisp)$Lisp

ELT_BVEC(v, range)$Lisp boolean

Description

 

Example

ELT_BVEC(v, range(v, i - mn))$Lisp

not_BVEC(v)$Lisp boolean

Description

 

Example

not_BVEC(v)$Lisp

devaluate(S)$Lisp::OutputForm  

Description

'devaluate' produces "type name", which uniquely identifies type. The name suggests that is is inverse of 'evaluate'. Actually you can massage result of 'devaluate' and pass to Lisp 'eval' to get the same type. But 'devaluate' does _not_ produce OutputForm, namely, result of 'devaluate' contains raw representation of parameters which in general need to be converted to OutputForm.

Example

see this thread

outputDomainConstructor(S)$Lisp  

Description

obtain the name (domain expression) of a domain as a OutputForm in SPAD

'outputDomainConstructor' calls 'devalute', but needs to do extra work. There are same tricky corner cases when printing types. 'outputDomainConstructor' is supposed to know how to handle them. Any method of printing types which does not ultimately go via 'outputDomainConstructor' is buggy or is likely to be broken by future changes.

Example

see this thread

   

Description

 

Example

 





metadata block
see also:
Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.