Showing posts with label REPL. Show all posts
Showing posts with label REPL. Show all posts

Friday, February 19, 2016

Red console view GUI

This is a simpler example to paste into a Red console to test the GUI basics of using the view dialect.

view [
    below
    tgl: text "Some test text"
    text 400x30 bold italic blue font-size 16 "Text with properties"
    button "Click Me" [tgl/text: "Text Changed!"]
    field 400 "SELECT this text then Type something into this entry field"
    area 400x200
]

A Red script might declare that it needs the view module in its header.

The above script was tested with the Feb 19 2016 build of Red.





Tuesday, December 14, 2010

rlwrap for the Curl shell

It is really essential to get a wrapper around some REPL's - the Curl shell is an example.

I run
rlwrap /opt/curl/surge/8/bin/curl --shell
which gives sane keystrokes and a command history.  If you are a client web developer coming over to the server-side, it is as essential a tool as egrep.

Friday, December 10, 2010

node.js REPL

I do like the node.js REPL.
The classic test is to enter 3 > 2 > 1

But consider this
/opt/curl/surge/8/bin/curl --shell
Entering 3 > 2 >1 gives a much better response.

Curl is an expression-based language - can you name another in which 42 > x > 0 evaluates to a success?

But let's stick to curl for now:  enter the string exit
Now that is a respectable result.  Douglas Crockford, applied science is not a popularity contest.

Simulate loosing your bearings for a moment and enter exit()

Are you convinced that JavaScript variables should always use var?  If so, enter
let answ:int = 42
Note the echo behavior is not annoyig.  To see answ enter answ or {value answ}
To change the value of answ, try
{set answ=65565}
So I such an
ln -s /opt/curl/surge/8/bin/curl xcurl
since the folks as curl.com failed to protect Curl from cURL.

And an icurl.sh gets you your rlwrap xcurl --shell

And to exit the REPL
{exit}
When Crockford talks about the origin of JavaScript and the involvement of SUN, he leaves out a few details.  His audience may not need to know about Self or Strongtalk.
But when Crockford lays out the weaknesses of JavaScript prior to ECMAScript5 he neglects to mention Curl.  Just as he neglects to mention Rebol or Io.  But at a GoogleTechTalk?  Were those talks intended to be misleading? Biased?

I do like JavaScript just as I do like Python (for my own needs.)  But Python is wrong for applications which must be tamper-proofed on the server-side.  Python dynamic objects in that regard are scary.  JavaScript is worse.  And Curl is (for now) absent on the server-side.

As for node.js, Curl has offered event loops in closures since forever.  and for generators, see RolledRandom at curl.com

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 aboutus.org