<thelema>
you should be able to adapt this for your language.
<rgrinberg>
thanks!!
<thelema>
maybe with a stack to hold the pending close symbols
<rgrinberg>
ya that was my first thought but i thought maybe there would be an easier way
<rgrinberg>
since that's what I would do if i was hand parsing it
<wmeyer>
the easiest way to do it is to have a stateful lexer, nest variable will indicate nesting, whenever nest is greater then 0 you print each char to a Buffer but not (* *) then if you hit *) and nest is 1 you skip removing it.
<thelema>
rgrinberg: if there were an easier way, I bet the creators of ocamllex would have used it
<wmeyer>
you basically collect chars to buffer when nest is 0 uncoditioally. Increment nest at (* and remove if nest is <> 0. Decrement nest on *) and remove after that if nest is <>0.
<wmeyer>
ocamllex is not a parsing tool! it's very powerful for a lexer though.
<rgrinberg>
wmeyer, ya thanks i think i understand how to do it
<wmeyer>
you can do it online easily with a script
<wmeyer>
rgrinberg: there is no other way.
<rgrinberg>
out of curiosity, would it be easier to do this with a too like parsec?
<wmeyer>
nope
<wmeyer>
rgrinberg: it would be much slower that #1, and you don't want to tokenize before right? that means you will run parser combinator for each char.
<wmeyer>
rgrinberg: stateful lexer is powerful enough for this task
<wmeyer>
rgrinberg: easier maybe yes or no
<wmeyer>
depending
<wmeyer>
one of the many advantages of libraries like Planck (Parsec for ocaml) is that they don't need a separate build step
<wmeyer>
but in time of ocamlbuild that surely not a big deal
<rgrinberg>
i also like experimenting in the toplevel with them
<rgrinberg>
with ocamllex/yacc it's harder to code interactively
<wmeyer>
true
fraggle_ has quit [Ping timeout: 246 seconds]
fraggle_ has joined #ocaml
Progster has quit [Ping timeout: 246 seconds]
emmanuelux has quit [Quit: emmanuelux]
<rgrinberg>
wmeyer, thanks i got it to work. didn't bother with the matching delimiters though. (} and {) will also work but w/e
<wmeyer>
rgrinberg: good, you are welcome
TDJACR has quit [Ping timeout: 276 seconds]
<pippijn>
I would like ocaml's normal (non-polymorphic) variants to be restrictable
tac has joined #ocaml
<pippijn>
like type foo = FooOne | FooTwo;; type bar = BarOne of [< FooOne]
mjonsson has quit [Remote host closed the connection]
<thelema>
pippijn: well, FooOne isn't a type...
<pippijn>
`FooOne isn't a type, either
<pippijn>
(as far as I know)
<thelema>
ok, this is true; [`FooOne] is a type... and you want subsets (and supersets?) of regular variants to avoid the hashing and maybe get better error messages?
<pippijn>
yes
BiDOrD has joined #ocaml
<pippijn>
to avoid the hashing
<thelema>
the hashing is done at compile-time
<pippijn>
ah
<thelema>
it's the identifier -> an int
<pippijn>
another point is [< Module.FooOne]
<thelema>
ah, module-scoping...
<pippijn>
yes
BiDOrD_ has quit [Ping timeout: 246 seconds]
<thelema>
that you don't have with polymorphic variants...
<thelema>
Of course you can simulate with [< Module_FooOne]
<thelema>
but there's no real scope on that
kissmekate has joined #ocaml
caligula__ has quit [Ping timeout: 272 seconds]
caligula__ has joined #ocaml
kissmekate has quit [Remote host closed the connection]
<pippijn>
I don't understand where the 2.4GB "live memory" comes from
bzzbzz has quit [Read error: Connection reset by peer]
bzzbzz has joined #ocaml
Yoric has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Kakadu has joined #ocaml
<samposm>
github labels my ocaml-projects "C" (not "OCaml") because they contain a C-library that has more code than the actual project. And the C-project is not "C" because it contains so much auxiliary textfiles. :-(
<ker2x>
i started to learn haskell too. but i ... mmm... i'm exploring other langage as well :)
<ansx>
keep on learning haskell :)
<ker2x>
huh ? why ?
<ansx>
it's way more useful than ocaml ;)
<hcarty>
ker2x: I started learning Haskell, found OCaml, then stuck with OCaml for 'real' work
<hcarty>
So you now have two data points to work from :-P
<ocp>
ansx: what are you doing here ?
<ansx>
ocaml research
<ker2x>
hcarty: acutally, that's what i tought. Haskell is very fun but OCaml seems to be more "real world oriented". not sure why.
<ocp>
then, stay passive
<ansx>
which leads me to think that this langage is essentially flawed
<hcarty>
ansx: Less trolling please. Reasons to use one language vs the other = good; Blanket statements bashing one language without reason = bad
<ker2x>
ho well actually i know why. it's used in industry. like... prover, static analysis, ...
<hcarty>
ker2x: I liked both but I found OCaml to be more accessible and better suited to my tastes.
<hcarty>
ker2x: Jane St., Citrix and others use it for general applications as well
<ben_zen>
ansx: why do you say that OCaml is essentially flawed? About the only serious flaw I can find is the Marshal module; everything else about it is very clean (if more strongly-typed than anything else I've ever worked with.)
<ker2x>
i have no idea if it may be usefull for sysadmin stuff. but i never seen any functional language used for sysadmin tool yet :)
<ker2x>
hcarty: i follow Jane St. RSS
<ansx>
for instance, on 32bits architecture you're exposed to a lot of integer overflow issues because the upped bound (max_int) is 1G
<hcarty>
ker2x: They claim to use OCaml for sys admin purposes :-) But I don't know any details regarding how they do so.
<ocp>
you mean, after the "Linspire" experience with OCaml ?
<ansx>
thus you can't open files > 1Gb because the stdlib tries to use llseek which may return values > 1G
<ansx>
you can't lock memory, nor you can securely wipe it
<ansx>
the 32 bits limitations makes it almost unusable for production on x86 & arm
<f[x]>
ansx, educate yourself
<ker2x>
this*
<f[x]>
ansx, those that you enumerated are not real problems on 32-bit
<ocp>
ker2x: link ?
<hcarty>
ansx: I've opened lots of files >1G on a 32bit system using OCaml. I haven't worked on a 32bit system in a while, but I didn't have any trouble with it ~5-6 years ago.
<f[x]>
the only semi-real 32-bit problems are string and array size limitations
<ocp>
OCaml has a LargeFile module, that provides lseek over 64 bits integers
<f[x]>
all other problems are 32-bit itself
<ker2x>
ocp: in my google readed. let me check
<ocp>
not a good idea to use TypeRex, now, as it does not support 4.00.1
<ocp>
(nor 4.00.0)
<ben_zen>
yup ... I had a sad when I tried to use it.
<ocp>
wait for the next version...
<ocp>
we are trying to simplify it, i.e. making it less powerful, but easier to use/install
<ansx>
f[x]: no they're not
<ansx>
32 bits is 2^32 bits while ocaml ints are 2^30
<ansx>
making them incompatible with most system calls returning unsigned int
<ansx>
(or size_t)
<ocp>
ansx: use Unix.LargeFile, and you get no 32 bits limitations on files
<ansx>
yeah so the "usual" API should not be used?
<ocp>
the "usual" API is for the compiler itself, everybody else uses other libraries
<ansx>
so you provide an stdlib which should not be used as a standard...
<ansx>
that's what I consider flawed
<ansx>
same for silent overflows on syscalls
<ocp>
ansx: the "stdlib" is minimalistic, that's all
<ocp>
the compiler's developers left the standard library to be developed by the community
<ocp>
being a compiler writer does not mean you are a good library writer
mcclurmc_away is now known as mcclurmc
<ansx>
ok so they built the Unix module
<ocp>
(although the stdlib is pretty good for data structures)
<ansx>
the exact same lacking support for any re-entrant syscall?
<ansx>
like gethostbyname_r or such
<f[x]>
those are not posix
<ocp>
no, they provided what you need: a way to call C functions by yourself
* ker2x
don't care. i'll learn it anyway
<ansx>
I'm not saying that nothing is good in OCaml, but you have alternatives that provides a more consistent dev env
<ocp>
that's what the community is currently working at
<ocp>
Inria, OCamlPro and OCamllabs are working together to address all these problems that have been there for years
<ocp>
OCamllabs has just been created, and OCamlPro is just one year old
<ocp>
give us some time...
<ker2x>
aww... *sigh* : OCaml offers a full array of imperative features. In particular, variables, arrays, and record components can be declared as modifiable.
<ocp>
ker2x: what's the problem ? you can decide not to use them...
<hcarty>
In the mean time, Core and Batteries do a nice job of filling in the gaps in the INRIA standard library
<ker2x>
is there something like fortran where you can declare a function to be "pure" ?
<ker2x>
so you can know if a function have an eventual side-effect
<hcarty>
ker2x: No, not in the core language at least
<ker2x>
ok
<ocp>
ker2x: actually, one strenght of OCaml is that you can mix pure and impure code
<ocp>
for example, you can go for only pure code, and then notice that some data structure would be much more efficient with some impure implementation
paolooo has quit [Ping timeout: 245 seconds]
<ocp>
then, you abstract the type, to keep the interface pure, but you can implement some functions with impure code
<ker2x>
yes yes, i understand. i language without any kind of side effect (no IO) is totally useless. i just hope there is an easy way to know if a function (you didn't wrote) is pure or impure.
<ker2x>
s/i/a/
<ker2x>
well, still reading :)
<ker2x>
Pattern matching \o/
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<ker2x>
i'm not sure to understand :
<ker2x>
OCaml's evaluation strategy is strict. A lazy evaluation regime may be simulated, when required, via explicit suspensions. Thus, it is possible, for instance, to manipulate potentially infinite data streams.
<ker2x>
i know what lazy/strict is but still.... it mean that it's struct by default but there is some kind of special magic to make it lazy ?
<ker2x>
explicit suspensions ?
<hcarty>
ker2x: lazy (print_string "Hello")
<hcarty>
That expression wouldn't print anything until 'forced'
<hcarty>
let result = Lazy.force some_lazy_value in ...
fliang has joined #ocaml
<ker2x>
thank you
<pippijn>
ker2x: nothing magic about it
<hcarty>
You're welcome. You can also pattern match lazy values.
ankit9 has quit [Quit: Leaving]
<ker2x>
pippijn: :)
<ker2x>
The Objective Caml toplevel, version 3.11.2
<ker2x>
humpf. thank you Ubuntu LTS ...
<hcarty>
ker2x: You can use ocamlbrew to compile a newer version
|jbrown| has quit [Read error: Operation timed out]
andreypopp has quit [Quit: sleep]
andreypopp has joined #ocaml
GnomeStoleMyBike has joined #ocaml
ocp has quit [Quit: Leaving.]
ocp has joined #ocaml
<ker2x>
haaaaa ocaml have curryfication. that's why it use the the same int -> int -> int as haskell (probably the opposite actually). good good
<thizanne>
« the opposite » ?
<ker2x>
well, err... how to say in english...
<thizanne>
do it in french
<ker2x>
can do :)
<thizanne>
there is also #ocaml-fr btw
<thizanne>
but it's quite inactive
<ker2x>
c'est probablement ocaml qui a inspiré haskell et pas l'inverse. d'ou le "opposite" :)
<thizanne>
aucun n'a inspiré l'autre
<thizanne>
ils ont tous les deux la même source
<ker2x>
ha
<ker2x>
k
<adrien>
"the other way round"
<ker2x>
ha yes, thank you. :)
<ker2x>
so it's inspired from ? ML ?
<thizanne>
from lambda calculus
<ker2x>
^^
ocp has quit [Remote host closed the connection]
gnuvince has quit [Ping timeout: 246 seconds]
<ker2x>
So, if it have currying it have partial function application (not sure about the word) ? like : let addThree = +3 ?
<Qrntz>
right
<ker2x>
lovely
<Qrntz>
except you'll have to write that as «let add_three = ( + ) 3»
<ker2x>
ok ok :)
<thizanne>
ker2x: that's the very point of curryfication
<Qrntz>
(the underscore between words instead of camelCase is common OCaml function naming style, that's purely visual)
fusillia has joined #ocaml
<ker2x>
it's odd that a langage named OCaml doesn't use camelCase :)
<companion_cube>
usually it's used, but for types
<ker2x>
k
<Qrntz>
types and module names
<Qrntz>
although everybody is free to choose his own style
<ker2x>
i'll follow commonly used coding style
<thizanne>
ker2x: camelCase starting by a lower case is sometimes used for classes
<hcarty>
ker2x: The most common format seems to be underscores for things starting with lowercase letters, camel-case elsewhere.
<hcarty>
let foo_bar = "baz"
<hcarty>
module FooBar = ...
|jbrown| has joined #ocaml
<flux>
and maybe FOO_BAR for module types?
<ker2x>
-_-'
<flux>
we have it all! except camelCase
<thizanne>
let's use FOObAR for module types
<thizanne>
reversed camel cas §§
<ker2x>
err... please stay away from me :)
<flux>
thizanne, well, maybe not. but how about for REALLY constant values? let tHEvALUEoFpI = 4.0 *. atan 1.0
<flux>
it makes perfect sense because we cannot use capital letters for values, and C uses (often) capital letters for really constant values (ie. preprocessing macros)!
cago has quit [Quit: Leaving.]
fusillia has quit [Quit: Leaving]
avsm has joined #ocaml
andreypopp has quit [Quit: sleep]
fusillia has joined #ocaml
braibant has left #ocaml []
andreypopp has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<hcarty>
flux: Clearly this should be added to the code style guidelines!
Kakadu has quit [Quit: Konversation terminated!]
Tobu has quit [Quit: No Ping reply in 180 seconds.]
Tobu has joined #ocaml
OCamlGuy has joined #ocaml
andreypopp has quit [Quit: sleep]
OCamlGuy has quit [Quit: OCamlGuy]
fusillia has quit [Quit: Leaving]
andreypopp has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
Neros_ has joined #ocaml
Neros has quit [Ping timeout: 246 seconds]
djcoin has quit [Quit: WeeChat 0.3.9]
OCamlGuy has joined #ocaml
xavierm02 has joined #ocaml
Kakadu has joined #ocaml
OCamlGuy has quit [Quit: OCamlGuy]
tane has joined #ocaml
metadave has joined #ocaml
<ker2x>
is there a way to know the definition of a function ? like ":t" in haskell's REPL
<ker2x>
please ? :)
<Kakadu>
try to write her name
<thelema>
ker2x: you can get the type of a value (including functions) by just typing the name followed by ;;
Yoric has quit [Ping timeout: 260 seconds]
<ker2x>
+# (List.fold_left);;
<ker2x>
- : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a = <fun>
<ker2x>
yay \o/
<ker2x>
thx
hkBst has quit [Quit: Konversation terminated!]
<ker2x>
time to go home
<ker2x>
have fun !
<ker2x>
*hugs*
ker2x has quit [Quit: hop hop]
avsm has quit [Quit: Leaving.]
jamii has joined #ocaml
GnomeStoleMyBike has quit [Ping timeout: 265 seconds]
tac has joined #ocaml
tani has joined #ocaml
milosn has quit [Ping timeout: 246 seconds]
andreypopp has quit [Quit: sleep]
tane has quit [Ping timeout: 260 seconds]
Xizor has joined #ocaml
OCamlGuy has joined #ocaml
chambart has quit [Ping timeout: 256 seconds]
answer_42 has quit [Remote host closed the connection]
ninegrid has quit [Ping timeout: 265 seconds]
ninegrid has joined #ocaml
answer_42 has joined #ocaml
gnuvince has joined #ocaml
caj has joined #ocaml
caj has left #ocaml []
caj has joined #ocaml
caj has left #ocaml []
caj has joined #ocaml
OCamlGuy has quit [Quit: OCamlGuy]
caj has left #ocaml []
mcclurmc is now known as mcclurmc_away
caj has joined #ocaml
GnomeStoleMyBike has joined #ocaml
ftrvxmtrx has joined #ocaml
milosn has joined #ocaml
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 246 seconds]
caj has quit [Quit: Leaving.]
caj has joined #ocaml
fliang has quit [Ping timeout: 264 seconds]
OCamlGuy has joined #ocaml
arneis has joined #ocaml
caj has left #ocaml []
Cyanure has quit [Ping timeout: 246 seconds]
smondet has joined #ocaml
sivoais has quit [Ping timeout: 256 seconds]
Neros_ has quit [Read error: Connection reset by peer]
OCamlGuy has quit [Ping timeout: 260 seconds]
Neros has joined #ocaml
sivoais has joined #ocaml
OCamlGuy has joined #ocaml
OCamlGuy has quit [Quit: OCamlGuy]
emmanuelux has joined #ocaml
Yoric has joined #ocaml
andreypopp has joined #ocaml
sepp2k1 has quit [Read error: Connection reset by peer]
sepp2k has joined #ocaml
milosn has quit [Ping timeout: 255 seconds]
tac has quit [Ping timeout: 245 seconds]
milosn has joined #ocaml
ontologiae has quit [Read error: Connection reset by peer]
ontologiae has joined #ocaml
OCamlGuy has joined #ocaml
sepp2k has quit [Remote host closed the connection]
tufisi has quit [Read error: Operation timed out]
Snark has quit [Quit: Quitte]
tufisi has joined #ocaml
sepp2k has joined #ocaml
smerz has quit [Read error: Connection reset by peer]
OCamlGuy has quit [Quit: OCamlGuy]
sivoais has quit [Quit: leaving]
sivoais has joined #ocaml
_andre has quit [Quit: leaving]
Cyanure has joined #ocaml
sepp2k has quit [Remote host closed the connection]
ontologiae has quit [Ping timeout: 276 seconds]
tani has quit [Remote host closed the connection]
tane has joined #ocaml
answer_42 has quit [Quit: WeeChat 0.3.9]
sepp2k has joined #ocaml
tac has joined #ocaml
tane has quit [Quit: Verlassend]
tane has joined #ocaml
sepp2k has quit [Remote host closed the connection]
oriba has joined #ocaml
emmanuelux has quit [Ping timeout: 246 seconds]
chambart has joined #ocaml
tane has quit [Quit: Verlassend]
paolooo has joined #ocaml
hyperboreean has quit [Remote host closed the connection]
fraggle_ has quit [Remote host closed the connection]
Xizor has quit [Quit: So yes it's mIRC under wine under debian double peche capital. ;) I'll soon see in kfreeBSD.]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
fraggle_ has joined #ocaml
metadave has quit [Remote host closed the connection]
chambart has quit [Ping timeout: 246 seconds]
xavierm02 has quit [Quit: Leaving]
chambart has joined #ocaml
Cyanure has quit [Remote host closed the connection]
Neros has quit [Ping timeout: 260 seconds]
Neros has joined #ocaml
chambart has quit [Ping timeout: 246 seconds]
smondet has quit [Ping timeout: 276 seconds]
jamii has quit [Ping timeout: 240 seconds]
oriba has quit [Quit: oriba]
tac-tics has joined #ocaml
avsm has joined #ocaml
mjonsson has joined #ocaml
avsm1 has joined #ocaml
milosn has quit [Ping timeout: 256 seconds]
avsm has quit [Ping timeout: 255 seconds]
gnuvince has quit [Ping timeout: 260 seconds]
andreypopp has quit [Quit: sleep]
Tobu has quit [Quit: No Ping reply in 180 seconds.]
Tobu has joined #ocaml
milosn has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
paolooo has quit [Ping timeout: 245 seconds]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<wmeyer>
hi
<wmeyer>
pippijn: yeah, it's odd. Today I had to spend more time on my daytime job, just got back home
tac-tics has quit [Quit: Page closed]
<wmeyer>
pippijn: Polymorphic variants are cool - but they have some limits. I thought about using them for AST rewriters too, but they don't cut, especially with a lack of Camlp4 type reflection