<ayrnieu>
imperial programming focuses on the 'Emperor', or the person that makes all the orders to bring about change, whereas function programming focuses on the 'functions', or the processes that bring about the change. Also, imperial programming systems tend to like to supress minority peoples as they extend the Empire.
* tautologico
hears the imperial march from star wars
<mattam>
so it's what's advocated by Antonio Negri in the eponym's book ?
* mattam
really needs some sleep
<tautologico>
so do I
<platypus>
:)
<platypus>
can someone explain to me the diff btwn recursion and tail recursion ?
CiscoKid has joined #ocaml
CosmicRay has joined #ocaml
<CosmicRay>
Hi... I'm looking for the opposite function to String.escape
<CosmicRay>
any ideas? :-)
vezenchio has joined #ocaml
gwe3`wats has joined #ocaml
gwe3`wats has quit [Remote closed the connection]
bk_ has joined #ocaml
<ayrnieu>
platypus - a smart enough compiler can optimize a tail-recursive function call into a 'jump' -- e.g, if function A calls function B which tail-calls function C, C returns to A rather than B. Since machines have finite stack space, the absense or presence of tail-call optimization affects programming style.
<platypus>
ayrnieu, so tail recursion is good right ?
<ayrnieu>
platypus - tail recursion exists, good or bad. I like tail-call optimization, though =)
<tautologico>
in short, a recursive tail call can be optimized to a jump (instead of a function call)
<ayrnieu>
(not to confuse tail-call optimization with more specific tail-recursive-call optimization)
<platypus>
could u guys umm give me like a simple example ?
<platypus>
tautologico, is there a 'jump' in ocaml ?
<tautologico>
platypus: no, I meant when the code is compiled
<platypus>
right
<tautologico>
platypus: have you read the tutorial mentioned in the topic ?
<platypus>
where ?
<platypus>
i am reading the oreily book but there are stuff i don understand
<CiscoKid>
I wouldn't think of ;; as end of command.
Callidus has joined #ocaml
<platypus>
CiscoKid, what would consider ';;' ?
<CiscoKid>
Read that tutorial. It explains a lot. I've been programming ocaml for a while and I'm reading it now. :)
<platypus>
yup doing that now :)
<platypus>
ah ; is like bash's &&
<samx>
bzzzt
<CiscoKid>
Um, that's not bash, that's bourne shell. It's more like ; in bourne shell.
<CiscoKid>
However, it's not quite there, either, since the last command's return value is returned from it.
* CiscoKid
gets annoyed when people write ``bash'' scripts.
<bk_>
?
<samx>
a;b would be like let _ = a in b
<CiscoKid>
I think the tutorial's explanation of it as unit -> 'b -> 'b makes a lot of sense.
<samx>
;; is really mostly just for use with the toplevel, to indicate that you want to feed what you've written to it.. when writing code in a source file, i'd recommend not to ever use it
<platypus>
CiscoKid, what do you use ocaml for ?
<CiscoKid>
I solved one of the IPSC problems with it last night. :)
<platypus>
CiscoKid, in ur work ?
<CiscoKid>
I've got a mail server maintenance app that runs nightly on my SunOS 4.1.4 box. It reads through my ~100k email messages, figures out which ones are recent, but not in gzip format, and then gzips them (zlib binding).
<platypus>
and u wrote that in ocaml ?
<CiscoKid>
Oh, at work...I wrote a native CDB interface and a few utilities around it, along with an app that deals with all of our incoming manufacturing data (and data from our partners) and builds a big cdb with all of the information for all of the built devices we know about.
<platypus>
CiscoKid, umm one thing could u explain what is meant by unit() -> 'b -> 'b ?
<platypus>
what is the diff btwn 'a and 'b ?
<platypus>
'a is the first value ?
<CiscoKid>
Ooh, I've got this kick-ass backup thing I wrote. I pass my nightly DB dumps through it (about 2.2GB) and it chops them into blocks, md5s them, and compares them to the previous days' md5s to see if any blocks have changed. Any changed blocks get encrypted on the way to disk (via gpg). Anything that hasn't changed is hard linked as an individual block to the previous day's dumps. I basically get level 9 dumps with level 0 storage.
<CiscoKid>
'a and 'b are different types (but the types aren't specified, all you know about them is that they're different)
<CiscoKid>
In fact, 'a and 'b may be the same type, but they don't have to be.
<CiscoKid>
I'm pretty sure all of this is covered in that tutorial. It's very well written.
<CiscoKid>
(even though it's from the perspective of a perl programmer).
<platypus>
CiscoKid, do you do perl ?
<CiscoKid>
I rather despise perl. I've had multi-million line perl codebases in the past. I threw it all away and haven't intentionally touched any since. I don't see the point.
<platypus>
multi-million ? wow
<ayrnieu>
I, by contrast, know and vague appreciate Perl (enough to find silly anti-Perl remarks annoying) -- I've just found it monumentally uninteresting for some time now.
<ayrnieu>
also, vaguely.
<platypus>
ayrnieu, ah u use erlang also ?
<ayrnieu>
platypus - yes. Why do you ask?
<platypus>
naw just saw u on #erlang
<platypus>
and CiscoKid too :)
<CiscoKid>
I can't imagine how anyone who has had to manage that much perl written by any number of developers would retain an appreciation for it.
ne1 has joined #ocaml
<ayrnieu>
I've only ever had to manage what Perl I wrote myself. That probably helps.
<samx>
perl has lots of advantages over ocaml.. like lots of 3rd party packages and actually a community that is alive :-)
<CiscoKid>
Yeah. My last encounter with perl was helping a friend with a pretty bad bug in Digest::SHA1. It would give the incorrect answer if used incorrectly (as opposed to giving no answer). I had to explain to the author that the stuff he was saying you couldn't do could be done in a straightforward way).
<ne1>
I prefer quality over quantity.
<Smerdyakov>
samx, you say that in a channel with 47 people?
<samx>
smerdy, yes
<Riastradh>
...#perl, by comparison, has six times that number...
<CiscoKid>
I've rarely seen a perl program without a bug. The safety of ocaml is what really drew me in. By the time it compiles, it mostly runs.
<ayrnieu>
and #perl, by comparison, has a huge community outside that number.
<ne1>
There is no benefit in getting into the majority. Too much competition there.
<Smerdyakov>
The average ML community member is much smarter than the average Perl community member.
<samx>
smerdy, there is a difference between having some people on a channel, and having an active community that makes the language grow to be larger than it is.. but then again, ocaml dev team knowingly tries to kill any such community activity
<ayrnieu>
Smerdyakov - an equivalent assertion to "Perl has more popularity than the average ML", AFAICT.
<CiscoKid>
Kind of reminds me of a friend of mine who says he's going to learn C# when he gets out of college...apparently there's some appeal for people to learn the most diluted thing.
<ne1>
The Law of Large Numbers assert that you cannot get both quantity and quality. Pick your poison.
<ayrnieu>
samx - how do they knowingly try to do that?
<ne1>
(I chose quality because I figured out how to work around the lack of quantity.)
<CiscoKid>
I agree the ocaml team is really damaging the community by impeding the language growth. It seems like there are plenty of people wanting to fix up missing pieces of the language.
<ne1>
(From the first day I put OS/2 on my computer, my fate had been determined.)
<samx>
smerdy, i haven't seen any studies done on the smartnes of an average ml user versus an average perl user.. i'm sure an average ml user is much more knowledged about programming languages though
<CiscoKid>
I wonder how many people have implemented Extlist.iteri :)
<ne1>
What is Extlist?
<CiscoKid>
Extra list stuff.
<Smerdyakov>
There's a reasonable chance that Standard ML will grab almost all OCaml usage when MLton has a few more improvements made.
<samx>
smerdy, ...and averages dont matter, because top 5% of best perl users are a LOT more people that the whole ml community :-)
<CiscoKid>
My last company had over 100 perl programmers (I wasn't one of them). I had to fix all of their mistakes. I can assure you we had some of the bottom 5%. :) Having to explain to these people that stuff was processed in the order in which it appeared really lowered morale.
<ne1>
Top 5% of Americans are a lot more people than IQ>150 people, too.
<samx>
ne1, so, are uou implying that an average ml user has an IQ over 150?
<ne1>
No, I am implying that the top 5% Americans are still very stupid.
* ayrnieu
regrets contributing to this silliness, now.
<Riastradh>
This whole argument is silly. That the average OCaml user is smarter than the average Perl user is a useless declaration; that Perl has sheer numbers is a useless declaration.
<Smerdyakov>
ne1, as opposed to the top 5% of all people?
<ne1>
But why am I arguing and letting you poke holes into my arguments? I should make you argue so I can poke holes into yours. If Perl is so nice, why is there no theorem prover written in it? Why is Perl not implemented in Perl itself?
<ayrnieu>
ne1 - you don't poke holes in his argument, you make entirely new, unrelated arguments.
<ayrnieu>
by which I mean 'questions'.
<samx>
ne1, lets see.. perl is low on theorem provers, because perl is done by and for people who need to get small things done dirty, versus being done by theorists who have the luxery of not needing to get anything done on a timescale of under a couple of years, and not being forced to compromise
<ne1>
Surely someone can get a small dirty theorem prover done?
<samx>
ne1, and for perl not being implemented by perl.. because perl community doesnt care on the underlying implementation, but what the current implementation allows them to do
<ne1>
not practising what one's preaching? even the C bigots know better.
<samx>
ne1, surely. i'm sure you could go hack perl, and get a theorem prover done quick enough, in ocaml, perl, oz, erlang, whatever happens to melt your butter
<CiscoKid>
I don't know, perl doesn't seem to make all that much easier for me. It certainly makes things harder to get right in my experience.
<ne1>
But Perl is supposed to have the benefit of the Law of Large Numbers!
<ne1>
There was a year during which I was thrilled about Perl. Then I found that I consistently wrote comments saying "this function takes parameters of type X and returns type Y". (I did that all the time with Lisp too.) After a while I got the point.
<samx>
cisco, there's different level in programming language.. on a core language semantic level, surely ocaml is far stronger.. on a standard library, ocaml is surely much cleaner, but more limited.. on 3rd party extension level, ocaml totally dies against perl.. on an industry level.. ocaml?
<ayrnieu>
ne1 - in what Lisp?
<ne1>
On the industry level, perl is a toy and only sysadmins use it.
<CiscoKid>
Industry's a bad metric. Personally, I've got deployed apps at my company in ocaml (more of mine are deployed in ocaml than perl or python). Industry mentality is the thing that has a lot of using java in inappropriate ways.
<samx>
ne1, last i knew, sysadmins were a large stakeholder in the industry level
<ne1>
Depends on which industry.
<ayrnieu>
ne1 - in which Lisp did you write such comments all the time?
<ne1>
Common Lisp.
<samx>
cisco, noone is arguing about if industry choices are sane or not, but that they are important in the sense on being able to be employed using your language and being able to do business based on your language
<ayrnieu>
ne1 - er, why didn't you just declare the types? Or do you mean that you always wrote comments on what your Lisp functions returned?
<CiscoKid>
I'm trying to get our sysadmins off of perl. When they have a bug it keeps me from getting the data I need for reporting, or worse...they've deployed part of the wrong app before.
<ne1>
sysadmins are worst when they are developers wannabe.
<platypus>
CiscoKid, u got that right about java ... i bet if i wuz lookin' fer a job and i told them i knew ocaml vs java they wouldn't even bat an eyelid
<CiscoKid>
The most successful programmer I've met to date was a smalltalk programmer. That's what frustrates me about the ``follow the industry'' crowd.
<ne1>
I know of no Lisp that lets me declare types and checks them.
<CiscoKid>
vs? Know both. erlang is *way* more suited to my group than java.
<platypus>
CiscoKid, what do you define as 'successful' ?
<Riastradh>
ne1, Common Lisp, and Python certainly performs static type analysis...
<Riastradh>
(by Python I refer to the cmucl compiler)
<CiscoKid>
Successful: Guy who works three months out of the year and just wanders around the rest.
<platypus>
ah
<platypus>
efficiency
<samx>
cisco, i can tell you there are a lot more smalltalk programmers employed writing java, than smalltalk programmers employed writing smalltalk
<platypus>
:)
<ne1>
Last time I wrote in Lisp it was 10 years ago. Too late now.
<Riastradh>
And, if I'm not mistaken, it was true with cmucl ten years ago.
<CiscoKid>
Heh, that's the difference between being able to get a job and being able to get a good job. :)
<ne1>
I had no cmucl.
<ayrnieu>
ne1 - all Common Lisp systems allow you to declare types. I only know that the python (SBCL uses it as well) compiler makes extensive use of this information, though.
<CiscoKid>
It's like I told my friend who said he was going to learn C# to get a job...``aim low.''
<Riastradh>
'Had no cmucl?'
<ayrnieu>
ne1 - unfortunately, I think that Common Lisp systems used to treat type declarations as permission to do no type checking.
<ne1>
There was not even a WWW 10 years ago. How was I supposed to hear about cmucl, if I were not in cmu?
<Riastradh>
How were people supposed to year about UNIX if they weren't at Bell Labs...?
<ne1>
Unix got sold and installed at every school. cmucl and ml didn't.
<Riastradh>
I'm sure if you paid attention to relevant Lisp mailing lists or newsgroups you would have heard of cmucl.
<ne1>
Why should I?
<Riastradh>
Uh, because someone on such mailing lists or newsgroups would surely have mentioned it.
<ne1>
Why should I care?
<Smerdyakov>
ne1, you're at CMU now?
<ne1>
No.
<Riastradh>
ne1, uh, because you were writing Lisp code then.
<Smerdyakov>
ne1, you were 10 years ago?
<samx>
...would've heard about cmucl, unless eric naggum ran them out before being able to listen long enough...
<ne1>
Look, my school did not install it, my profs and TAs did not talk about it. End of story. Not my fault.
<Riastradh>
It's not your fault you decided to be oblivious to the world outside your school?
<sundeep>
Smerdyakov: why do you think mlton would take over ocaml?
<Smerdyakov>
Responsiveness of the authors to the community
<sundeep>
does it have an irc channel?
<ne1>
You make it sound like every Windows user ought to read Windows newsgroups. Hilarious.
<Smerdyakov>
No
<Smerdyakov>
(Not that I know of, at any rate)
<CiscoKid>
Hmm....mlton doesn't seem to support a lot of what I use.
<samx>
smerdy, i've been on mlton mailing list for couple of years now, and i see mlton team respond to the community very quickly every time when the community sends their one or two montly emails to the list
<Riastradh>
ne1, you make it sound like every Windows user ought to ignore every other Windows user. Equally hilarious.
<Riastradh>
And every other OS while they're at it.
<Smerdyakov>
samx, there is a very active (public) developers' list.
<Smerdyakov>
CiscoKid, like?
<samx>
smerdy, ahh.. i've been missing out
<ne1>
I did not ignore every other Lisp user. I paid due attention to many Lisp users, namely my prof, my TA, and my classmates.
<CiscoKid>
I've got deployed OCaml apps I rely on that are running native on OS X and SunOS 4.1.4.
<ne1>
Look, do you know predicate logic?
<Riastradh>
CiscoKid, native on OS X?
<CiscoKid>
ocamlopt
<CiscoKid>
runs like wind
<Riastradh>
Er, wait, GUI apps?
<samx>
smerdy, ..though i would not mind seeing mlton drive past ocaml.. the ocaml dev team is way too research oriented
<CiscoKid>
No, no GUI apps.
<CiscoKid>
Perhaps I should've said darwin. :)
<Riastradh>
(sorry, the word 'GUI' mentally snuck into your message there, confusing me momentarily)
<ne1>
Riastradh doesn't know basic predicate logic. He mixes up forall-not with not-forall.
<Smerdyakov>
CiscoKid, this is why I said I think MLton can overtake OCaml, not that it is a dominating choice now.
<Smerdyakov>
CiscoKid, you'll notice OS X on the MLton to-do list, for example. :)
<CiscoKid>
Yeah, I'd like to fire it up, but it won't run on my computer right now, so I'll have to take your word for it. :)
<Smerdyakov>
CiscoKid, AND it has a C back-end, which should work on OS X today.
<ayrnieu>
Smerdyakov - GUI OS X? =)
<CiscoKid>
I'll see what happens.
<Smerdyakov>
ayrnieu, why not?
<CiscoKid>
Heh, well, the LaTeX docs almost built.
kinners has quit ["leaving"]
<ne1>
How do you write the type declaration "f : [(int,int,bool)] -> ((int,int),(int,int)) -> [(int,int,bool)]" in Lisp?
<ne1>
I probably mean int*int*bool list -> (int*int)*(int*int) -> int*int*bool list
wmg has joined #ocaml
samx has left #ocaml []
<platypus>
the type 'ref' means reference ?
<CiscoKid>
A reference has to be a reference of something, much like a list has to be a list of something.
wmg has left #ocaml []
sundeep has quit ["Client exiting"]
sundeep has joined #ocaml
sundeep has quit [Client Quit]
sundeep has joined #ocaml
sundeep has quit ["Client exiting"]
sundeep has joined #ocaml
sundeep has quit [Client Quit]
sundeep has joined #ocaml
vezenchio has quit ["look at you, hacker, a pathetic creature of meat and bone, panting and sweating as you run through my corridors; how can you ]
<skaller>
fun puts: cptr[char] -> int = 'puts($a)';
<skaller>
fun sscanf[t]: t -> int = 'sscanf($a)';
<skaller>
fun putw: int * ptr[FILE] -> int = 'putw($a)';
<skaller>
fun gets: ptr[char] ->
<skaller>
that's the top of the Felix one for stdio.h
<skaller>
It seems easy to make an Ocaml equivalent
<skaller>
just need an *.mli file instead plus a C wrapper for the RHS parts in quotes
gim has joined #ocaml
<fab__>
what does the generator do with things like enums or #defined flags or'ed together in a call to open?
platypus_ has quit [Read error: 54 (Connection reset by peer)]
<skaller>
enums are ints
<skaller>
macros are not visible at the moment
<skaller>
to use it at the moment you have to produce a preprocessed C file
<skaller>
so all the macros are gone
<skaller>
that could be fixed if i had a C preprocessor written in Ocaml
Snark has joined #ocaml
<skaller>
or just cheat, and scan the files for all #defines, which i what i will do first
<Snark>
slt
<skaller>
270 headers processed at the moment
<fab__>
what i meant is, you cant see from the header files, what the #defined constants are for, only from additional documentation. a hand crafted wrapper would allow the flags only at the right places
<skaller>
indeed
<skaller>
that applies to lots of things
<skaller>
which functions are real?
<skaller>
which structure members really need accessors?
<fab__>
yes
<skaller>
which enums are enumerations and which are bitstrings?
<platypus>
is there a date module for ocaml ?
fab__ is now known as _fab
<skaller>
at present flxcc is just a single program built as part of Felix
<skaller>
there is no clean division between the front and back end
<skaller>
there are global constants
<skaller>
it doesn't work properly yet either -- the front end is MUCH harder
<skaller>
the basic idea is that the lowest possible level wrapper is the best to start with
<skaller>
so no typemaps
<skaller>
it is actually possible to make very good guesses about intent
<_fab>
maybe the could be some kind of "hint language" for flxcc, which lets it restrict the generated wrapper
<skaller>
yeah, there is a crude one
<skaller>
i'm moving all the hard coded hacks into it :)
shammah has quit ["Leaving"]
<_fab>
where can i find information about flxcc?
<skaller>
the source code?
<skaller>
there is a cursorary explanation on the web
<skaller>
argg .. redhat 9 .. so badly built ..
<platypus>
skaller, ah i agree !!
<skaller>
damn
<skaller>
i have to kill my X server to fix up stupid GTK crap .. back in a second
<skaller>
how can those morons designed such garbage
<skaller>
I would execute them for deliberate fraud
<skaller>
designing a new system like gtk which isn't reentrant should be capital offense
<_fab>
do you use the "# lineno filename" lines after preprocessing for seperation into modules?
<skaller>
yeah partly
<skaller>
the parser tracks the location of every definition
<skaller>
it outputs a list of definitions
<skaller>
each one is a typedef, function, or whatever
CiscoKid has quit ["'night everyone"]
<skaller>
so i just make a hashtable of definitions keyed by the filename it came from :)
<skaller>
and provide a 'merge' statement in the control file to cheat
<skaller>
by remapping some filenames into other
<skaller>
this is NOT ENOUGH
<_fab>
what is the advantage of processing all files together instead of the files required for each library
<_fab>
?
<skaller>
well, if you use the C preprocessor, you know for sure that provided the header files
<skaller>
are actually sane ...
<skaller>
you will get closure
<skaller>
every type used will actually be defines
<skaller>
er .. 'defined'
<skaller>
however, it would be nice to do it incrementally
<skaller>
the problem is that C doesn't
<skaller>
and C programmers, being hackers, use every stupid preprocessing trick in the book
<skaller>
so you *could* just do the input processing and only write certain things out
<skaller>
but then you'd be generating dependencies on things that might not exist
<skaller>
or might be different to what you think
<skaller>
SWIG can do this
<skaller>
but .. have a look at math.h on your system :)
<skaller>
hmm .. :)
<skaller>
..
__DL__ has joined #ocaml
<skaller>
another answer to your question is 'aliasing'
<skaller>
if C says "typedef X Y" then X and Y can both be used in a function prototype
<skaller>
in the target language, we need ONE abstract type and a type alias
<skaller>
not two abstract types
<_fab>
yes, in math.h the preprocessor is used a lot... imho a language should make the preprocessor superfluous by providing language constructs
<skaller>
I agree
<skaller>
Felix tries
<skaller>
the constant folder can already fold conditionals over constant expression
<_fab>
maybe even conditional compilation could be solved this way
<skaller>
see last comment
<skaller>
but it isn't enough
<skaller>
you can write this in Felix:
<skaller>
val x = if 1 then 1 else fred endif;
<skaller>
woops, actually this:
<skaller>
val x = if true then 1 else fred endif;
<skaller>
notice 'fred' is undefined
<skaller>
no problem
<skaller>
the constant folder rewrites the term to be
<skaller>
val x = 1;
<skaller>
so when it comes to binding and typing, 'fred' isn't there to mess it up
<skaller>
so you can do 'well structured conditional compilation'
<skaller>
without using the preprocessor
<skaller>
but of course the arguments of the conditional must be syntactically properly formed expressions ..
<skaller>
they cannot be *definitions*
<skaller>
and they can't be arbitrary code fragments
<skaller>
this *reduces* the need for a preprocessor but it doesn't eliminate it
<_fab>
hhm, but doesnt it solve conditional compilation without #ifdef? or are there some cases where it doesn't work?
<skaller>
it won't handle definitions
<skaller>
for example:
<skaller>
#ifdef UNIX
<skaller>
fun dlopen : string -> library = "dlopen($1)";
<skaller>
#elifdef WINDOWS
<skaller>
fun dlopen : string -> library = "load_library($1)';
<skaller>
#endif
<skaller>
I can't use a conditional expression here, because the arguments are *statements*
<skaller>
not expressions ..
<_fab>
ok
<skaller>
A possible workaround ....
<skaller>
if WINDOWS goto windows;
<skaller>
fun dlopen ....
<skaller>
goto done_dlopen;
<skaller>
windows:>
<skaller>
fun dlopen ...
<skaller>
done_dlopen:>;
<skaller>
this is executable code in theory
<skaller>
even though it happens to jump around definitions
<skaller>
so I *could* make the compiler execute it
<skaller>
right now I can do this using the syntax macro processor
<skaller>
macro if WINDOWS goto windows
<skaller>
fun dlopen ...
<skaller>
macro goto done_dlopen;
<skaller>
....
<skaller>
the syntax macro processor is Turing complete -- it has a goto
<skaller>
syntax macros respect scopes
<_fab>
so you never know if a compilation will finish ;)
<skaller>
they manipulate parts of the already parsed parse tree, not strings
<skaller>
there is an execution limit :)
<skaller>
it was 10,000 lines
<skaller>
heh .. but some of the flxcc generate interfaces were longer than that
<skaller>
and it broke the compiler so i had to increase it to 100,000 lines :)
<skaller>
BTW: the idea with Felix is to provide TWO levels of abstraction:
<skaller>
(a) allow the programmer to nuke himself
<skaller>
(b) try to stop the programming tripping over on a banana skin
<skaller>
So for example: an Academic Teacher can prepare a system for students
<skaller>
by binding some nice C libraries
<skaller>
and then turn off the ability to make bindings
<skaller>
so the Student is locked into only using high level stuff
<_fab>
how can he do this?
<skaller>
the simplest dirty way is to add a pragma that makes certain words not keywords
<skaller>
for example if I make 'goto' no longer a keyword, you can't parse goto statements :)
<_fab>
hhm, what more "cleaner" ways have you in mind?
<skaller>
since the lexer uses a table of keywords this can be done easily
<skaller>
I have advertised on sourceforge for a Security Guru to assist in designing that
<skaller>
one also wants to restricy execution environments, for example for an Apache module
<skaller>
eg: stop 'open(f,"w")' working: don't allow any way to open files to write
<skaller>
so the answer to your question is: I don't know
<skaller>
felix is potentially highly secure
<_fab>
i started porting a subset of prevayler to ocaml, it would be very useful there if you could restrict the user of the library in which ways he can access data structures
<skaller>
what's prevayler?
<_fab>
prevayler is some kind of in memory database using snapshots and logs
<skaller>
ok
<_fab>
but the coder has to define the transactions himself and make sure they are deterministic etc.
<skaller>
checkpoint/restart model ..
<_fab>
yes
<skaller>
the oldest and simplest
<skaller>
if you're wrapping by hand you can always use functional abstraction
<skaller>
that's the idea behind Felix binding technology
<_fab>
what do you mean by functional abstraction? at least in ocaml there is no way i am aware of to restrict side-effects
<skaller>
make each data type abstract
<skaller>
and then provide accessors
<skaller>
ah
<skaller>
yeah, that's a design problem in Ocaml
<_fab>
the data types are defined by the user of the library himself... so i can't restrict him
<skaller>
how does the user define them?
<skaller>
directly in Ocaml?
<_fab>
yes, using a functorial interface
<skaller>
ah, so not 'directy'
<skaller>
yu have data type constructors
<_fab>
yes
<_fab>
well, if i understand you correctly...
<skaller>
so there are some constraints on what the user can build ..
<skaller>
but they're just those enforced by Ocaml static typing
<_fab>
it uses a functor and an input signature
<skaller>
yeah
<_fab>
but the input signature contains a function, which the module calls, and i cant express that this function must be purely functional
<_fab>
or at least deterministic
<skaller>
sure you can -- in the documentation :)
<skaller>
what you mean is you can't make the Ocam compiler enforce that constraint
<skaller>
:(
<_fab>
yes
<skaller>
Felix enforces it
<skaller>
functions can't have side effects
<_fab>
i thought felix is imperative?
<skaller>
It has procedures as well as functions :(
<skaller>
procedures can have side effects
<skaller>
i mean, they MUST have side effects or they're useless :)
<_fab>
can procedures have return values?
<skaller>
no
<_fab>
ok
<skaller>
the result is a bit clumbsy to use though
<skaller>
syntactically
<_fab>
why?
<skaller>
var result: int;
mattam has quit [Read error: 60 (Operation timed out)]
<skaller>
operation(&result, other_data);
<skaller>
you have to make a variable to hold outputs
<skaller>
it can't even be a value
<skaller>
Felix has vars and vals:
<skaller>
val x = 1; // immutable
<skaller>
var x = 1; // mutable
<skaller>
obviously val's a better :)
<_fab>
:)
<skaller>
vals can't be addressed
<skaller>
so they're subject to heavy optimisation :)
<skaller>
var's don't need to be initialised ..
<skaller>
so they're subject to core dumpings and worse .. :(
<_fab>
so felix is able to segfault without interfacing c?
<_fab>
does it use automatic memory management?
<skaller>
Ocaml can infinitely recurse too?
<skaller>
Yeah, Felix has a garbage collectr
<skaller>
Functions are called like in C: using the machine stack
<skaller>
Procedures use continuation passing
<_fab>
what is continuation passing?
<skaller>
oh, a procedure is a C++ class with a 'resume()' method
<skaller>
to execute a procedure you do this in C++:
<skaller>
while(p) p=p->resume();
<skaller>
each 'resume()' call does a bit of the procedure and then yields
<skaller>
the reason is control inversion ..
<skaller>
there is a primitive 'read x'
<skaller>
this gets the next event from the input queue
<skaller>
it does that by yielding control to the driver
<skaller>
the stack has to be empty when you yield control