jscheme

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Natural Language Processing
51.Net
52.Parser
53.PDF
54.Portal
55.Profiler
56.Project Management
57.Report
58.RSS RDF
59.Rule Engine
60.Science
61.Scripting
62.Search Engine
63.Security
64.Sevlet Container
65.Source Control
66.Swing Library
67.Template Engine
68.Test Coverage
69.Testing
70.UML
71.Web Crawler
72.Web Framework
73.Web Mail
74.Web Server
75.Web Services
76.Web Services apache cxf 2.2.6
77.Web Services AXIS2
78.Wiki Engine
79.Workflow Engines
80.XML
81.XML UI
Java Source Code / Java Documentation  » Scripting » jscheme 
JScheme Scripting Languages
License:
URL:http://jscheme.sourceforge.net/jscheme/main.html
Description:JScheme is a dialect of Scheme with a very simple interface to Java, called the Javadot notation .
Package NameComment
build Build package This package is used to build JScheme from Java and Scheme sources. It also contains several ClassLoaders.

The scripts src/build/bootstrap or src/build/bootstrap.bat can be used to build jars and documentation. The JScheme make script is src/build/jscheme-bootstrap.scm.

dclass (define-class)

The macro (define-class) lets you define Java class in Scheme. To Java, such a class looks just like and other Java class. The only difference is that its behavior is implemented in Scheme.

The classes in this directory are simple metaclasses used by (define-class). These classes are organized more consistantly than the java.lang.reflect classes are. Their behavior is written in JScheme.

Example

For example, to sort a vector of integers, say, #(5 2 1 3 9 6 2 7 1) using Arrays.sort, you need an implementation of java.util.Comparator. This can defined like:

  (define-class
    (package frog)
    (import java.util.Comparator)
    (public class Compare implements Comparator)
    ;; Design issue, fields must be public for Jscheme code to access.

    (public Procedure predicate)	

    (public Compare (Procedure predicate)
     (.predicate$ this predicate))

    (public boolean predicate (Object a Object b)
     ((.predicate$ this) a b))

    (public int compare (Object a Object b)
     (cond ((.predicate this a b) -1)
	   ((.predicate this b a) 1)
	   (else 0)))

    (public boolean equals (Object that)
     (and (eq? (.getClass this) (.getClass that))
	  (eq? (.predicate$ this) (.predicate$ that))))

    (public int hashCode () 0))

You can then sort the vector with:

(let ((a #(5 2 1 3 9 6 2 7 1)))
  (Arrays.sort a (frog.Compare. <))
  a)

which produces:

#(1 1 2 2 3 5 6 7 9)

The (define-class) macro looks similar to the equivalent Java class. It consists of a sequence of clauses. The clauses can occur in any order, though it is convention to follow an order close to Java's.

define-class syntax

define-class = "(" "define-class" head member* ")"

head         = package import* class|interface
package      = "(" "package" PACKAGENAME ")"
import       = "(" "import" FULLCLASSNAME|PACKAGENAME ".*" ")"

class        = "(" modifier* "class" extends? implements? ")"
interface    = "(" modifier* "interface" extends? ")"
extends      = "(" "extends" CLASSNAME+ ")"
implements   = "(" "implements" CLASSNAME+ ")"

member    = constructor|field|method|static
constructor  = "(" modifiers* name "(" arg* ")"
exp* ")"
field        = "(" modifiers* type name (= value)? ")"
method       = "(" modifers* type "(" arg* ")" exp*")"
static       = "(" static exp* ")"

type         = Java type.
value        = exp
arg          = type name
exp          = {Scheme expression}
name         = {Java identifier}

Issues

  • (this) and (super) in constructor.
  • (.foo super ...) in methods.
  • Unnecessary recompilation.
  • Java class redefinition.
  • Debugging errors. Adding comments to java file?

Scheme files

Scheme files in this directory include:

elf

The elf package is software contributed by software elves, funded by lunch money. Elves, like hackers, write software for their own purpose, Luckily, sometimes they leave an editor buffer open that reveals what they've been up to. I've simply added some documentation and cleanup here and there.

I use a lot of this package every day. Studying these files, can help you learn JScheme and make effective use of Java API's.

interact

Provides classes that provide TTY-like (EMACS shell mode like) interaction to Java applications.

The class Interactor provides a Jscheme interactor that is useful for poking around Java applications, such as during debugging.

jlib JLIB JLIB provides several libraries written in JScheme and compiled to Java, so it is more informative to read the Jscheme code.
jscheme The standard API for JScheme.
Super Luzer
Last modified: Mon Dec 23 14:26:17 Eastern Standard Time 2002
jscheme.bsf
jschemeweb Provides a class that allows servlets to be written in various styles.
jsint The JScheme implementation.
using Sample code

Useful Examples of JScheme code

This package contains examples of using JScheme to enhance the Java experience. The JScheme code is designed to be viewable from a web browser as well as executed by JScheme, so one file serves as tutorial and code.

Topics:

  • run.scm provides shell scripting capability that is used to make JScheme. See src/build/jscheme-bootstrap.scm for an example.
  • command.scm provides a simple command line processor. New commands can be defined with the (define-command) macro. I use it for building and running Java applications.
  • Active.java provides active debugging capabilites to your Java application.
  • Dan Friedman wrote a very nice paper: Object Oriented Style which shows how to use define-syntax to write a Object Oriented extention to Scheme. friedman-init.scm initializes JScheme and loads Dan's code. This is a serious example of using macros!
  • siscnum.scm - redefines the arithmetic operators in JScheme to use the SISC numeric tower (sisc.sourceforge.net). You must then explicitly converted computed numbers back to Java when using them in javadot calls, e.g.
w_w_w__.__jav_a2___s___.__c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.