Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: Mattias Waldau <mattias.waldau@abc.se>
Cc: "'Diego Olivier Fernandez Pons'"
	<Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr>,
	caml-list@inria.fr
Subject: Re: [Caml-list] Two types of efficiency (Was Efficiency of 'a list)
Date: Mon, 05 May 2003 23:17:51 +1000	[thread overview]
Message-ID: <3EB6647F.2020008@ozemail.com.au> (raw)
In-Reply-To: <049301c312f7$12f58c10$0200a8c0@gateway>

Mattias Waldau wrote:

 
> It would be interesting to see how a typed scripting language (maybe
> built on top of ocaml) with advanced built-in datastructures (with
> syntax support) would look like.

There are two things you can look at:

(1) FISh 2 when it finally comes out,
will support general polynomial data structures
with functorial polymorphism: at the moment
only FISh 1 is available but gives the flavour:

http://www-staff.it.uts.edu.au/~cbj/FISh/

(2) Felix:

http://felix.sf.net

isn't nearly as ambitious, indeed, its
a stock Algol like language with a couple
of twists which includes heavy support for
purely functional programming with eager
evaluation.

At the moment, the only 'advanced' data structure
built-in to the language is the ability to
build O(n) regular expression matching used like:

	regmatch string_expr with
	| regexp1 => ...
	| regexp2 => ..

[and there is some hackery here ..]

Contrary to providing 'built-in' advanced
data structures, Felix is exactly the opposite:
it has no built-in data types at all.

Instead, it provides powerful data constructors
such as anonymous sums and products, as well as
functions of course. These are strong enough to
construct bool in the standard library.

In addition, it provides a way to lift data types
from C/C++. For example:

	type int = "int";
	fun add: int * int -> int = "$1 + $2";

Each of these "user defined primitives" is defined
in C/C++ and provided as an abstract data type,
accessed by user specified primitive functions
(like "add" above). Primitives can now also be generic:

	type vector[t] = "std::vector<?1>";

I'm explaining all this because in my opinion,
providing some fixed "efficient/advanced" data structure
"built-in" to the language is in fact suboptimal,
and unnecessary.

The trick, instead, is to provide CORE functionality
which can be used to conveniently construct and access
such data structures. For example you can write:

	s[1 to 20]

to subscript a string. It's just syntactic sugar for:

	subscript(s,1,20)

and subscript is just a function: for a given string like
type, the user has to define it.

Some of the other features that make Felix friendly
include an advanced overloading scheme which fixes
many of the problems in the C++ mechanism (and contrary
to GCaml, is even more "open" than the C++ mechanism)

The most advanced feature "builtin" is, in fact,
not a data structure but a control structure:
Felix performs blocking reads on a central message queue
by yielding control (without using hardware threading).
[I call the suspended states continuations, but technically
I think they're resumptions]

It is likely I will provided synactic sugar for
some other concepts such as iterators. What's important
in scripting languages, apart from automatic storage
management, is that the syntax be convenient.

There is nothing in Python dictionaries or Perl hashes
that can't be done in C++ or Ocaml: the primary advantage
is NOT that these data structures are built in.
What's important is the easy use which specific
syntax provides.

Felix will try to provide the convenience without actually
building anything in: instead, it provides a way to bind
the syntax to user defined types. Operator overloading
and the like are the simplest and easiest way to do this,
although it's painful compared with what FISh 2 seeks to do:
allow functorially polymorphic algorithms to be written.

I have to recommend consideration of the protocols
definitions in Python, and the container and iterator
definitions in the C++ Standard. Both of these
systems handle, in a different way, the notion
of Sequence and Associative Container fairly well.
Similarly, SQL embodies well the notions of relational
algebra (and in some sense is a generalisation of
sequences and associative containers).

Its clear, however, that no one has much idea
what to do with trees and graphs (yacc like parser tools
are the closest thing to tree management syntaxes, and they're
usual extrinsic rather than embedded in the language).

In the end, convenient use of advanced data structures --
and i don't  mean simply sequences and associative containers --
depends on theoreticians developing the right general
calculi to deal with them in a compact way.

Only then can language designers provide generalised
syntax that goes beyond overloading and stuff like

	address ["fred"] = "20 Smith St Paris"

-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-05-05 13:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-02 19:27 [Caml-list] Efficiency of 'a list Eray Ozkural
2003-05-03  5:43 ` Mattias Waldau
2003-05-03  8:16   ` Ville-Pertti Keinonen
2003-05-03 14:12   ` Vitaly Lugovsky
2003-05-03 18:43     ` Mattias Waldau
2003-05-03 20:01       ` Eray Ozkural
2003-05-03 23:17       ` Eray Ozkural
2003-05-04  2:08       ` cashin
2003-05-04  4:08         ` alc
2003-05-04  5:32           ` Ed L Cashin
2003-05-04  6:46           ` [Caml-list] Two types of efficiency (Was Efficiency of 'a list) Mattias Waldau
2003-05-04  7:35             ` John Max Skaller
2003-05-04 11:52               ` Olivier Andrieu
2003-05-05 11:04                 ` John Max Skaller
2003-05-04 16:48               ` brogoff
2003-05-04  7:43             ` Ville-Pertti Keinonen
2003-05-04 12:50               ` Eray Ozkural
2003-05-04 12:48             ` Eray Ozkural
2003-05-05  7:31             ` Diego Olivier Fernandez Pons
2003-05-05 11:11               ` Mattias Waldau
2003-05-05 13:17                 ` John Max Skaller [this message]
2003-05-05 11:49               ` Eray Ozkural
2003-05-05 11:57               ` Yaron M. Minsky
2003-05-05 13:32                 ` John Max Skaller
2003-05-06  2:49                   ` Nicolas Cannasse
2003-05-06 12:30                     ` Diego Olivier Fernandez Pons
2003-05-07  2:05                       ` Nicolas Cannasse
2003-05-05 16:38                 ` Diego Olivier Fernandez Pons
2003-05-05 18:05                   ` Eray Ozkural
2003-05-06 13:28                     ` Diego Olivier Fernandez Pons
2003-05-13 11:35                   ` [Caml-list] Data Structure Libraries (was: Two types of efficiency) Oleg Trott
2003-05-04  7:55           ` [Caml-list] Efficiency of 'a list Ville-Pertti Keinonen
2003-05-04 10:56             ` Neel Krishnaswami
2003-05-04 12:56               ` Eray Ozkural
2003-05-04 13:35                 ` Falk Hueffner
2003-05-04 12:38           ` Eray Ozkural
2003-05-04  8:07         ` Ville-Pertti Keinonen
2003-05-04 15:54           ` Ed L Cashin
2003-05-05 23:52           ` Garry Hodgson
2003-05-03 20:03   ` Eray Ozkural
2003-05-03 21:13 ` Lauri Alanko
2003-05-03 22:03   ` Eray Ozkural

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EB6647F.2020008@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=mattias.waldau@abc.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox