Well, I didn't like any of the pattern-matching libraries out there,
so I wrote another one. The api is similar to Fare Rideau's fare-
matcher, with a couple extra features, but the internals are much more
straightforward, at the expense of not supporting unification at all.
Incidentally, the title of this post is derived from a message I
posted here a few months ago, forwarding a message from Fare about
fare-matcher. c.l.l had recently been engaged in a troll war with Dr.
Frog, who had claimed that pattern matching in Lisp amounted to
Greenspunning ML. The title was meant to be a parody of Dr. Frog, but
maybe some people took it otherwise (if they noticed it). Anyway,
since I so rudely inflicted such an inconsiderate title on a post
about Fare's software, the least I could do was to take a well-
deserved dose of my own medicine.
So this library is called cl-match, and it uses the same s-expression
interface to ML-style matching as does fare-matcher, but it has a
couple extra features. It allows multiple occurances of variable
names, with implied EQL comparisons, and allows branch-specific guards
to be embedded in individual branches where alternative patterns are
allowed (OR patterns). The expanded code is optimized somewhat by
testing all single-branch patterns first. There's some documentation
here:
http://www.prairienet.org/~dsb/clmatch.htm
The main page has links to a user's manual, a page on the internals,
and a download directory. Please feel free to comment, criticize,
point out bugs, etc..
--Dan
------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/
danb wrote:
> So this library is called cl-match, and it uses the same s-expression
> interface to ML-style matching as does fare-matcher, but it has a
> couple extra features. It allows multiple occurances of variable
> names, with implied EQL comparisons, and allows branch-specific guards
> to be embedded in individual branches where alternative patterns are
> allowed (OR patterns). The expanded code is optimized somewhat by
> testing all single-branch patterns first.
Can you implement proper decision-tree-based optimizations by augmenting
Lisp with some kind of closed algebraic data types equivalent to ML's
variant types?
That is where the enormous performance advantages lie...
> There's some documentation here:
>
> http://www.prairienet.org/~dsb/clmatch.htm
>
> The main page has links to a user's manual, a page on the internals,
> and a download directory. Please feel free to comment, criticize,
> point out bugs, etc..
ML's pattern matching was designed to make it easy to convey
statically-checked constraints. I assume your Lisp implementation makes no
attempt to provide any static assurances at all. In which case, you may
find it more productive to Greenspun Mathematica's pattern matching
instead.
Also, you might like to reimplement this old benchmark using your new
library:
http://www.lambdassociates.org/studies/study10.htm
HTH.
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
On Apr 28, 8:23 pm, Jon Harrop <····@ffconsultancy.com> wrote:
> danb wrote:
> > So this library is called cl-match, and it uses the same s-expression
> > interface to ML-style matching as does fare-matcher, but it has a
> > couple extra features. It allows multiple occurances of variable
> > names, with implied EQL comparisons, and allows branch-specific guards
> > to be embedded in individual branches where alternative patterns are
> > allowed (OR patterns). The expanded code is optimized somewhat by
> > testing all single-branch patterns first.
>
> Can you implement proper decision-tree-based optimizations by augmenting
> Lisp with some kind of closed algebraic data types equivalent to ML's
> variant types?
Yes. It can be done.
> That is where the enormous performance advantages lie...
>
> > There's some documentation here:
>
> >http://www.prairienet.org/~dsb/clmatch.htm
>
> > The main page has links to a user's manual, a page on the internals,
> > and a download directory. Please feel free to comment, criticize,
> > point out bugs, etc..
>
> ML's pattern matching was designed to make it easy to convey
> statically-checked constraints. I assume your Lisp implementation makes no
> attempt to provide any static assurances at all. In which case, you may
> find it more productive to Greenspun Mathematica's pattern matching
> instead.
Of course the OP library does not implement the full blown unification
based ML type checking algorithm. It is because pattern (unification)
matching is a component (arguably the most important) of static type
checking. In other words, they are different things.
Cheers
--
Marco
On Apr 28, 3:28 pm, danb <·········@gmail.com> wrote:
> c.l.l had recently been engaged in a troll war with Dr.
> Frog,
What war are you talking about ? Single toad waving with plastic
sword, and took so much beating
that even heartless start to feel sorry about poor pond dweller.
Than somebody called Animal Protection Agency and show was over.
Slobodan
P� Wed, 30 Apr 2008 14:03:51 +0200, skrev Slobodan Blazeski
<·················@gmail.com>:
> On Apr 28, 3:28�pm, danb <·········@gmail.com> wrote:
>> �c.l.l had recently been engaged in a troll war with Dr.
>> Frog,
> What war are you talking about ? Single toad waving with plastic
> sword, and took so much beating
> that even heartless start to feel sorry about poor pond dweller.
> Than somebody called Animal Protection Agency and show was over.
>
> Slobodan
You might need a fortress to protect yourself.
(Check Guy Steele's current activeties at Sun.)
--------------
John Thingstad
On Apr 30, 2:23 pm, "John Thingstad" <·······@online.no> wrote:
> På Wed, 30 Apr 2008 14:03:51 +0200, skrev Slobodan Blazeski
> <·················@gmail.com>:
>
> > On Apr 28, 3:28 pm, danb <·········@gmail.com> wrote:
> >> c.l.l had recently been engaged in a troll war with Dr.
> >> Frog,
> > What war are you talking about ? Single toad waving with plastic
> > sword, and took so much beating
> > that even heartless start to feel sorry about poor pond dweller.
> > Than somebody called Animal Protection Agency and show was over.
>
> > Slobodan
>
> You might need a fortress to protect yourself.
> (Check Guy Steele's current activeties at Sun.)
What activities? http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere
A project inspired by Scala, Standard ML, and Haskell that runs on
JVM, no thank you.
cl/scheme, j/q, joy, prolog and erlang made a high threshold on what's
acceptable for me.
>
> --------------
> John Thingstad
Slobodan Blazeski wrote:
> On Apr 30, 2:23�pm, "John Thingstad" <·······@online.no> wrote:
>> You might need a fortress to protect yourself.
>> (Check Guy Steele's current activeties at Sun.)
>
> What activities?
> http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere A
> project inspired by Scala, Standard ML, and Haskell that runs on JVM, no
> thank you.
Inspired by Scala and Java maybe but not SML and Haskell (or OCaml, or F#).
Fortress is extremely verbose and fails to capture the productivity of ML
and Haskell. Scala is the same.
Fortress can't even represent "hello world" without many unnecessary
declarations including type declarations:
component HelloWorld
export Executable
run(args:String...):() = do
println("Hello, world!" )
end
end
Contrast with F#:
printf "Hello, world!"
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
On 30 Apr., 15:30, Dr Jon D Hoparound wrote:
> Fortress can't even represent "hello world" without many unnecessary
> declarations including type declarations:
Oh I see - that wouldn't fit the needs of your typical customer
then...
I could implement a domain specific language for you (and them) which
is optimized to generate type proven "hello world"s without needing
unnecessary declarations:
Here is the program:
"hello world"
interested?
Jochen Schmidt
On 33 Apr, 11:11, <jon.flying.at.com> wroted:
> printF "Hello worldF"
...sorry, forgot to mention:
The most important letter here is the 'F' (standing for, you know).
-JH
Jon Harrop schrieb:
> Slobodan Blazeski wrote:
>> On Apr 30, 2:23 pm, "John Thingstad" <·······@online.no> wrote:
>>> You might need a fortress to protect yourself.
>>> (Check Guy Steele's current activeties at Sun.)
>> What activities?
>> http://projectfortress.sun.com/Projects/Community/wiki/FortressStartHere A
>> project inspired by Scala, Standard ML, and Haskell that runs on JVM, no
>> thank you.
>
> Inspired by Scala and Java maybe but not SML and Haskell (or OCaml, or F#).
> Fortress is extremely verbose and fails to capture the productivity of ML
> and Haskell. Scala is the same.
>
> Fortress can't even represent "hello world" without many unnecessary
> declarations including type declarations:
>
> component HelloWorld
> export Executable
> run(args:String...):() = do
> println("Hello, world!" )
> end
> end
>
> Contrast with F#:
>
> printf "Hello, world!"
Not true.
You are complaining that the component above is more verbose than the
typical single liner.
The language specs http://research.sun.com/projects/plrg/fortress.pdf
lists this one-liner executable as:
export Executable
run(args) = print “Hello, world!”
and runs it with
$ fortress run HelloWorld.fss
The component holds an object, which is more than a single exe.
This is nice:
"Fortress allows recursive, and mutually recursive function definitions."
factorial (n) =
if n = 0 then 1
else n factorial (n − 1) end
Note that "n factorial (n − 1)" means "n * factorial(n − 1)".
The magic, invisible multiplication operator.