|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
questions about kawa (or possibly scheme)The main question is where I should look (if there is any such place) for answers to questions such as those below. I've never seriously used scheme. I do use common lisp. Is defmacro part of the latest scheme or a kawa addition? Is there a type-of function (to return the type of its argument) ? Is there something way to find what symbols have function bindings like *packages* and do-symbols ? with-input-from-string ? BTW, it took me a while to figure out that write returns (values). |
|
|
Re: questions about kawa (or possibly scheme)Don Cohen wrote:
> The main question is where I should look (if there is any such place) > for answers to questions such as those below. > > I've never seriously used scheme. I do use common lisp. > > Is defmacro part of the latest scheme or a kawa addition? defmacro is non-standard and strongly discouraged. Use define-syntax (standard), or define-syntax-case (a convenience macro on top of define-syntax - see the Kawa manual). > Is there a type-of function (to return the type of its argument) ? We should distinguish: a "type" is a compile-time property of a variable or an expression; at run-time objects have a reference to their "class". You can get the latter with the Java method getClass: (invoke foo 'getClass) or (foo:getClass) or just foo:class This returns the Java class which is a little lower-level than the Scheme types. I.e. (4:getClass) prints "class gnu.math.IntNum" rather than "Type integer", which is what you get if you just evaluate the "type expression" "integer". > Is there something way to find what symbols have function bindings > like *packages* and do-symbols ? Do remember that Kawa is very compiler-oriented. So, to a large extent is Scheme - especially R6RS. Function bindings may be local to a module or other scope, in which case they're not accessible from a symbol or package. Kawa does have packages and a way to get at symbols, but it's not really supported. What do you need this for? Perhaps you'r asking the wrong question? > with-input-from-string ? open-input-string or call-with-input-string > BTW, it took me a while to figure out that write returns (values). Yes. It and many similar functions that the Scheme standards specify as returning "unspecified" in Kawa have void type, which is equivalent to them always returning zero values. -- --Per Bothner per@... http://per.bothner.com/ |
|
|
Re: questions about kawa (or possibly scheme)Per Bothner writes:
> > The main question is where I should look (if there is any such place) > > for answers to questions such as those below. Since there's no answer, I guess this is the place. > > Is there something way to find what symbols have function bindings > > like *packages* and do-symbols ? > > Do remember that Kawa is very compiler-oriented. So, to a large > extent is Scheme - especially R6RS. Function bindings may be > local to a module or other scope, in which case they're not > accessible from a symbol or package. > > Kawa does have packages and a way to get at symbols, but it's > not really supported. What do you need this for? Perhaps > you'r asking the wrong question? I was hoping to browse the list and thus find functions/variables of interest. What's the proper way to find out what's there? I tried looking at the latest scheme spec index but I don't see things like write -- which I just guessed by luck after print didn't work. At a higher level the objective is to write applications in lisp (I'm hoping scheme will suffice) while using java for the UI. I've been assuming that it's easy from a java app to create a kawa process, pass it strings to read/eval/print, get the string outputs from print and put them into the java UI. Is this plan impacted by kawa being compiler oriented, or anything else that you can tell? |
|
|
Re: questions about kawa (or possibly scheme)Hi Dan-
In short, yes you can create a kawa 'process' in the way you describe. You can instantiate kawa.standard.Scheme and call its eval() methods. You shouldn't even notice that Kawa may be compiling and classloading under the hood. The Kawa docs are very good once you have a small grasp of Scheme. Start with the R5RS and also look at the SRFIs that Kawa supports (see section 3.1of the docs), especially SRFI 1. I find the 'format' procedure very useful for writing strings, see 3.14.5 My tip is to learn the Scheme/Java interface of Kawa and call out to Java for things you don't yet know how to do in Scheme. As you learn more Scheme you can go back and try to rely on Java less and less. Kawa is brilliant once you get into it, so don't give up and keep asking questions... Malcolm On 9 Sep 2008, at 20:45, don-kawa@... (Don Cohen) wrote: > Per Bothner writes: > >>> The main question is where I should look (if there is any such >>> place) >>> for answers to questions such as those below. > Since there's no answer, I guess this is the place. > >>> Is there something way to find what symbols have function bindings >>> like *packages* and do-symbols ? >> >> Do remember that Kawa is very compiler-oriented. So, to a large >> extent is Scheme - especially R6RS. Function bindings may be >> local to a module or other scope, in which case they're not >> accessible from a symbol or package. >> >> Kawa does have packages and a way to get at symbols, but it's >> not really supported. What do you need this for? Perhaps >> you'r asking the wrong question? > > I was hoping to browse the list and thus find functions/variables > of interest. What's the proper way to find out what's there? > I tried looking at the latest scheme spec index but I don't see things > like write -- which I just guessed by luck after print didn't work. > > At a higher level the objective is to write applications in lisp > (I'm hoping scheme will suffice) while using java for the UI. > I've been assuming that it's easy from a java app to create a kawa > process, pass it strings to read/eval/print, get the string outputs > from print and put them into the java UI. > Is this plan impacted by kawa being compiler oriented, or anything > else that you can tell? |
|
|
Re: questions about kawa (or possibly scheme)Don Cohen wrote:
> > Kawa does have packages and a way to get at symbols, but it's > > not really supported. What do you need this for? Perhaps > > you'r asking the wrong question? > > I was hoping to browse the list and thus find functions/variables > of interest. What's the proper way to find out what's there? > I tried looking at the latest scheme spec index but I don't see things > like write -- which I just guessed by luck after print didn't work. The "Kawa manual" (which is the core part of the Kawa website) historically has documented *extensions* and differences from standard Scheme (R5RS), so you needed to be familiar with R5RS. I'm trying to move away from that, and document all the standard Scheme functionality, merged into their logical place, but that will take a while. (I've also started on a tutorial, but that too will take a while.) I do recommend using the SVN version of Kawa, which as seen a lot of changes since the last release. The web-site docs are based on the released version, but you can get the updated documents from doc/kawa.texi - generate info or pdf or html from those. -- --Per Bothner per@... http://per.bothner.com/ |
|
|
Re: questions about kawa (or possibly scheme)* Don Cohen [2008-09-09 21:45+0200] writes:
> Per Bothner writes: > > > > The main question is where I should look (if there is any such place) > > > for answers to questions such as those below. > Since there's no answer, I guess this is the place. Darius Bacon's "Scheme for Common Lispers" could be useful: http://www.accesscom.com/~darius/writings/scheme-for-lispers.html > I was hoping to browse the list and thus find functions/variables > of interest. What's the proper way to find out what's there? > I tried looking at the latest scheme spec index but I don't see things > like write -- which I just guessed by luck after print didn't work. To list all variables in the REPL, I use something like this: (do ((enum ((<gnu.mapping.Environment>:current):enumerateAllLocations))) ((not (enum:hasMoreElements))) (format #t "~a~%" (enum:nextLocation))) But often there is no other way than to grep through Kawa's source code. > At a higher level the objective is to write applications in lisp > (I'm hoping scheme will suffice) while using java for the UI. > I've been assuming that it's easy from a java app to create a kawa > process, pass it strings to read/eval/print, get the string outputs > from print and put them into the java UI. > Is this plan impacted by kawa being compiler oriented, or anything > else that you can tell? This sounds like a good plan. The compiler-orientedness matters when you use modules: non-exported functions will be compiled down to JVM methods, and you can't no longer call them (easily) from the REPL. Redefining them is also not so easy. Of course, those issues are only relevant during development. The compiler is very useful when interacting with Java: you get compile time warnings when calling undefined methods etc. A slight annoyance when interacting with Lisp, is that Kawa's reader/printer treats `:' specially, i.e. you can't use CL-style symbols easily. E.g: ':foo => foo: Helmut. |
| Free Forum Powered by Nabble | Forum Help |