Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] ocaml complexity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] ocaml complexity
William Chesters wrote:
> 
> John Max Skaller writes:
>  >      The really BIG culture shift, in my opinion,
>  > is something much simpler: syntax.
> 
> I agree that's very significant.  C++-style syntax with camlp4,
> anyone? :)

I know there's a sort of smiley there, but this is more or
less what I'm working on: I'm developing a new programming
language, Felix, for C++ users, which has the main features
of functional programming, including closures, higher
order functions, variants, pattern matching,
modules, and garbage collection.

Felix provides overloading, uses {} to denote blocks
in which all definitions are recursive,
has type inference for variables but not functions,
uses SML/Ocaml type grammar, and binds cleanly
with C++ (partly because it's a C++ code generator).

Here's a complete working example, I hope it is
readable to both C++ and Ocaml programmers.
[I also hope 6! = 720, because that's the answer
that gets printed :=]

--------------------------------------------
header '#include <stdio.h>';

type bool = "bool";
type int = "int";
proc print: int = 'printf("%d\n",$1);';
fun sub: int * int -> int = "$1 - $2";
fun mul: int * int -> int = "$1 * $2";
fun gt: int * int -> bool = "$1 > $2";

fun fact(a:int): int
{
  fun f (a:int, p:int) : int {
    if(a>1) return f(a-1, p*a);
    else return p;
  }
  return f(a,1);
}

print (fact 6);

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr