jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp

Home Page:https://jscl-project.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot access some functions and macros

mmontone opened this issue · comments

I'm not being able to access some of the functions and macros, defstruct and concat in particular, no matter which package I use. What am I doing wrong?

Welcome to JSCL 0.5.1 (built on 6 November 2016)

JSCL is a Common Lisp implementation on Javascript.
For more information, visit the project page at GitHub.

CL-USER> (apropos "defstruct") 
... 
DEFSTRUCT (fbound)
DEFSTRUCT (fbound)
NIL
CL-USER> (defstruct foo x y)
ERROR: Variable FOO is unbound.
CL-USER> (apropos "concat") 
... 
JSCL::CONCAT (fbound)
JSCL::MAPCONCAT (fbound)
JSCL::CONCATENATE-STORAGE-VECTOR (fbound)
JSCL::CONCATF (fbound)
CONCATENATE (fbound)
CONCATENATED-STREAM (fbound)
CONCATENATED-STREAM-STREAMS (fbound)
MAKE-CONCATENATED-STREAM (fbound)
CONCATENATE (fbound)
CONCATENATED-STREAM (fbound)
CONCATENATED-STREAM-STREAMS (fbound)
MAKE-CONCATENATED-STREAM (fbound)
NIL
CL-USER> (disassemble #'concat) 
... 
ERROR: Function 'CONCAT' undefined
CL-USER> 

I've been able to access jscl::concat, but not concatenate for example.

CL-USER> (disassemble #'jscl::concat) 
... 
function JSCL_USER_CONCAT(values){var v1741=l3.value;
var I;
for (I=arguments.length-1-1;I>=0;I--)v1741=new internals.Cons(arguments[I+1],v1741);
var v1742=this;
return (function(){return (function(v1748){return l70.fvalue(values,v1748,v1741,l72);
})((function JSCL_USER_NIL(values,v1744,v1745){internals.checkArgs(arguments.length-1,2);
var v1746=this;
return (function(){return (function(){var SV1=v1744;
var R=SV1.concat(v1745);
R.type=SV1.type;
R.stringp=SV1.stringp;
return R;
})();
})();
}));
})();
}
NIL
CL-USER> (jscl::concat "lala" "adsf") 
... 
"lalaadsf"
CL-USER> (jscl::concatenate "la") 
... 
ERROR: Function 'CONCATENATE' undefined

concat is an internal function. You can still use it if you want to by prefixing the package:

(jscl::concat "foo" "bar")` ; => "foobar"

Similarly, we do not expose defstruct yet because we do not have a fully compatible implementation. But there is an internal def!struct macro which implements a subset of the functionality.

An example again in the REPL:

(jscl::def!struct person
  name
  age)

(make-person :name "david") ; => (PERSON "david" NIL)

Note that def!struct uses lists as the underlying structure for now. The issue #259 is about changing this to an internal 'storage-vector' type. I think after that issue we could expose defstruct to the COMMON-LISP package, even if it is not 100% compatible yet.

Thanks for the quick answer!

concatenate is not implemented either. Feel free to add it! :-)

https://github.com/jscl-project/jscl/blob/master/src/sequence.lisp

Ok. I get confused what is available and what is not when developing. I'm using apropos, but it doesn't seem to be useful.

For example:

CL-USER> (apropos "symbol-string") 
... 
SYMBOL-STRING (fbound)
NIL
CL-USER> (cl::symbol-string "lala") 
... 
ERROR: Function 'SYMBOL-STRING' undefined
CL-USER> (cl::symbol-string 'asdf) 
... 
ERROR: Function 'SYMBOL-STRING' undefined
CL-USER> (jscl::symbol-string 'asdf)
ERROR: Function 'SYMBOL-STRING' undefined

Do you have some tip so I get less annoyed by this?

I think you just found a bug in fboundp.

(fboundp 'concatenate) ; => T
(function-symbol 'concatenate) ; => ERROR...

I will create an issue for it. That should solve apropos as well.

I added it to the issue #268