Friday, June 29, 2007

a Rebol tip

If you are new to the Rebol language on Windows you may have noticed that there are 2 files named rebol.exe
One is in \core and one is in \view
If you have followed the wiki-book you may be in the habit of running \core\rebol.exe in which case you may hit two oddities: first, that console does not know how to respond to
and, second, that it cannot respond to
editor ""
or the more interesting
editor system/view

The answer is to launch Rebol only using the home directory view.exe
From there you can go back and forth to console and then return to ViewTop using the command

While you are at it, try
source build-tag
source to-email
type? {this and that}
reduce [ 2 + 3 + 5 7 ]
compose ["this" (21 + 21) "that"]
parse {this that these those} " "
and enjoy!

PS. Here are 3 links to console info:

Saturday, June 23, 2007

Missing Curl links which could be Surge links

At I have posted a list of selected missing links

Many are pages which reference some programming languages but not Curl. Some links are offered in the hope that someone can sort things out. In one case, at I had occasion to flip 'cURL' to 'Curl' in a 'Hello World' applet demo.

In any country in the world where English is not the second language, a modified Curl should be able to get a foothold as an alternative to using English-like CSS and JavaScript and Java and XHTML. In simplified-Chinese or in any ethnic-Sino setting, Curl would be a natural choice.
If there is to be a tidal Surge to raise the American barge, it may come only after the little boats have risen in the linguistic tributaries of the non-English world.

Wednesday, June 13, 2007

QTk scripting in Oz/Mozart

The relative neglect of oz/mozart compared to say, Scala, has an explanation.

Part of it must lie in the needless snags along the learning curve. Steep is fine; jagged bits, less so.

There is no learning Oz/Mozart without embracing their emacs mode. And tolerating their tutorial.

Do not begin with applications. An application will require at least one 'functor'.

Ignore the bits that say you are compiling. You are not. No tutorial code will compile. Just do as you are told (follow the instructions) and 'feed' in a line. Or 'feed' in a region. Or 'feed' in a buffer.

What they mean is pass a line, a selection or the file through the interpreter only.

Think of it as scripting in Oz/Mozart. Now you can open a window with widgets using an few lines of Qtk.

No language which interfaces to Tk should be hampered by such a tutorial or such documentation; the usual answer is to buy the somewhat pricey MIT book by Peter van Roy.

Try to understand that the people who are assessing the need to revise the on-line documentation already know oz/Mozart inside-out and cannot 'see' the bits that say 'compile' when nothing compiled at all. They think you know what they mean by 'pickle' and that you get the 'functor' jibe at Prolog. A module is a module. Sometimes in some language a class is just a module. And writing a fine tutorial is an art. If you can get the video intro to Revolution/Transcript/MetaCard to run under Windows using the required QT codec, you may actually see what I mean.

But hey, you could not script the Oz/Qtk way in C. The fact that it looks easier in Jython may be that you know java and python. But it is easier in Tcl/Tk wish. So the point must be what can be achieved in oz/Mozart and that may be as much as can be achieved with Scala and then some.

Watch this blog for a link to a tutorial and a concordance/commentary to their friendly-looking documentation. And just accept that all you need to know is in the oz/Mozart maillist.

Somewhere in oz, climbing a cliff on the way to the corner store.

Note: do try the QTk Prototyper.  The tutorial leaves out one essential: declare the Prototyper, as in

 declare Prototyper
[Prototyper]={ ["x-oz://system/wp/Prototyper.ozf"]}

Saturday, June 9, 2007

Jetty Lift Scala Tutorial for Windows XP

First install Jetty as a web server.
Open a cmd session in that Jetty directory (for this I use Microsoft PowerToys "Open Command Window" tool.)
In that cmd session, execute
java -cp . -jar start.jar

Open an IE browser and enter the address http://localhost:8080
When the web page comes up, click the Jetty test link
Go to the cmd window and enter CTRL-c to stop jetty

Now install Lift if you have not already done so.
Copy the Lift JAR file to jetty\lib
Copy the Lift Examples WAR file to jetty\webapps
restart jetty
refresh the localhost web page with the F5 key
This time click the Lift Examples link

Welcome to Lift on Jetty

Thursday, June 7, 2007

Scala and the interpreter

I have been looking at Prolog-like facilities implemented in languages which could benefit from something like the partially determined clauses found in Mercury for which there is no backtracking: a matching clause is found among a set of clauses or we fail.
There are interesting implementations of prolog available as add-ons to many languages including Scala.

I began my foray into Scala with a PDF by Martin Odersky which presented the following code:
def sort(xs: Array[int]): Array[int] =
if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }

This implementation of a quicksort chokes Scala when it is fed line-by-line to the interpreter by my own shell tool.
Here is one variant that keeps the interpreter waiting for more:
def sort(xs: Array[int]):
Array[int] = if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }

It is the sort of thing that those who script Perl are used to but might seem odd to someone from the functional-side whose interpreters would be waiting for the closing embrace.

If you would like to contribute to a portal on declarative+imperative, there is a new SmalltalkProlog portal that I have opened at

Friday, June 1, 2007

redirecting Rebol stdin/stdout under Windows

Rebol has a console interpreter which I wished to wrap in a smarter Win32 console shell that would screen my typical typo's, maintain a history across sessions and a few other useful features to exploit the Rebol parser.

My console wrappers at the moment are both Smalltalk console applications written in Dolphin Smalltalk: ConsoleShell and ConsolePipe. ConsoleShell understands commands for several language configurations and writes to a named pipe opened and echoed by ConsolePipe1; ConsolePipe2 takes STDOUT and pipes it to a chosen NamedPipe to feedback to an IDE running the ConsoleShell.

The problem that I faced was to pipe out from rebol.exe as it is not enough just to use the -w option to prevent a window from opening.

The answer lay in a Rebol script not unlike what you might use to loop a Perl interpreter. In my test case, the following pipeline works under Windows XP:
ConsoleShell | ConsolePipe1 | rebol.exe -w -c --do "forever [attempt [print do ask %~]]" 2>&1 | ConsolePipe2

The input is to my shell and the output appears in a destination window fed by a named pipe.
Unless you ran taskmgr you would not know that rebol.exe was running.

The two key bits are the -c flag and the print block. You also have to ignore the obvious and set the prompt ( in my case '->' ) with the '%' as indicated and you must wrap the script in dbl-quotes.

Now my ConsoleShell pipes into Rebol and Rebol outputs into my chosen Windows NamedPipe. This should work with any 2 wrappers - you might want to try with Tcl and expect. The Rebolution continues ...