Reto,

Thanks for providing a link to your sources. From what I could it is base on the version available from Google Code. Meanwhile the Scala interpreter made its way into Sling [1] and underwent quite some changes. Many of which solve problems which you solved in a different way in your code base (i.e. synchronization). Eventually it would be nice if there would be a single common script engine which might even make its way back to the Scala folks. After all there where discussions over there to this respect.

The main issues from the Sling side are ATM:

- Dependency on Sling. Mainly because the compiler needs to output the class files into the repository.

- Scripts need to follow Sling specific cermony [2]. I'm not really happy with this for several reasons. The LineDeductingReporter could come in handy here.

- The variable bindings mechanism needs to be improved. I see there is some effort in clerezza regarding this.

Michael


[1] http://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/scala/
[2] http://people.apache.org/~mduerig/scala4sling/scala4sling.pdf

Reto Bachmann-Gmuer wrote:
the clerezza project (which has been accepted for apache incubation last
week) contains some scala support as well [1]. It's based on sling-code but
extended to provide a ScriptEngineFactory. It takes to declare the bound
variables using a type visible to the "interpreted" scala code in the OSGi
runtime.

This ScriptEngine is used for standard scripting but also for
"ScalaServerPages", here Scala is used with a DSL to render a
response-resource (a node in an RDF graph). The following is an example of a
ScalaServerPage:

def um(s: Any) = new UriRef("http://clerezza.org/2009/05/usermanager#"+s)
def perm(s: Any) = new UriRef("http://clerezza.org/2008/10/permission#"+s)
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
    <head>
        <title>Permissions for user {res/um("user")/FOAF.name}</title>
    </head>
    <body>
    {for (permission <- res/um("permission")) yield
        <div id="permission">
            {permission/perm("javaPermissionEntry")*}
        </div>
    }
    </body>

</html>

While ScalaServerPages would probably be hard to use withing Sling I think
it would be good to pool the efforts for having a single
javax.script.ScriptEngineFactory.

From the clerezza-code the following wqould have to be done:
- refactor ScalaInterpreter (taken from Sling) for synchronization issues
- enhance algorithm to find best runtime-visible interface of a bound object
(and possibly use implicit conversions to cast the object from one
implemented interface to the other)


Cheers,

1. The code should be moved to the invubator svn very soon, currently its
here: http://scm.trialox.org/main/org.clerezza.scala/


On Tue, Dec 1, 2009 at 7:32 PM, Carsten Ziegeler <cziege...@apache.org>wrote:

Michael Dürig wrote:
[1]. A simple hello world programm looks basically like this in Scala:

  println {
    <html>
      <h1>{ "Hello " + currentNode("title") }</h1>
      Today is { Calendar.getInstance.getTime } <br />
      My path is { currentNode.path }
      { Tree(currentNode).render }
    </html>
  }

Yes, and this looks fine except the println statement surrounding
everything. Maybe if we can get rid of that one we are already one step
further?
Well that shouldn't be too difficult to do I think. It was actually my
decision to *explicitly* println. I can try to come up with another
patch later.

Cool!

Carsten
--
Carsten Ziegeler
cziege...@apache.org



Reply via email to