jscheme

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
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.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.