According to Users Manual and Reference,;; pass data by context reference
(set 'Mydb:data (sequence 1 100000))
(define (change-db obj idx value)
(setf (obj:data idx) value))
(change-db Mydb 1234 "abcdefg")
(nth (Mydb:data 1234)) → "abcdefg"
Therefore(?), obj:data cause the following error message:Symbol creation in contexts
3.When an unknown symbol is encountered during code translation, a search for its definition begins inside the current context. Failing that, the search continues inside MAIN for a built-in function, context, or global symbol. If no definition is found, the symbol is created locally inside the current context.
Code: Select all
ERR: context expected in function match : obj
called from user defined function $reader-event
But these are not the disadvantage, sorry.(define (change-db obj idx value)
(setf ((eval (sym 'data obj)) idx) value))
(define (change-dbx obj name idx value)
(setf ((eval (sym name obj)) idx) value))
(Mydb "data" (sequence 11 20))
(define (change-dby obj idx value)
(setf ((obj "data") idx) value))
(define (change-dbz obj name idx value)
(setf ((obj (string name)) idx) value))
By the way,
throw-error is error-event ?Using catch and throw
As an alternative to catch, the throw-error function can be used to catch errors caused by faulty code or user-initiated exceptions.