<discocaml_>
<psychokitty> Just trying to think of hacky ways to emit the relevant DEDENT tokens if one wished to parse a whitespace significant grammar. One (cursed) idea was to basically insert special tokens (at extreme cost for each line) into the lex buffer.
<discocaml_>
<psychokitty> Other generators work on states (that you can change in semantic actions) and allow you to mutate the lex buffer, i.e. `yybegin` and `yypushback` in JFlex. Not saying this is good, but it makes the problem straightforward.
trillion_exabyte has quit [Ping timeout: 255 seconds]
trillion_exabyte has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
sagax has quit [Quit: Konversation terminated!]
hrberg has quit [Ping timeout: 255 seconds]
hrberg has joined #ocaml
hsw has joined #ocaml
hackinghorn has joined #ocaml
hackhorn has joined #ocaml
hackinghorn has quit [Read error: Connection reset by peer]
bobo_ has joined #ocaml
spip has quit [Ping timeout: 248 seconds]
chrisz has quit [Ping timeout: 246 seconds]
chrisz has joined #ocaml
John_Ivan_ has quit [Ping timeout: 255 seconds]
hackhorn has quit [Quit: Leaving]
rf has quit [Quit: Leaving]
rom1504 has quit [Ping timeout: 248 seconds]
rom1504 has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
trev has joined #ocaml
<discocaml_>
<NULL> Why not pass the current indent level as an argument to the le er?
<discocaml_>
<NULL> Why not pass the current indent level as an argument to the lexer?
bgs has joined #ocaml
jao has quit [Ping timeout: 255 seconds]
bgs has quit [Remote host closed the connection]
Haudegen has joined #ocaml
<discocaml_>
<psychokitty> The current indent level is something the lexer must compute.
<discocaml_>
<psychokitty> In most implementations, the lexer maintains a stack of indentation levels (initially seeded with a single 0). Then, when the lexer in the "program" mode sees a newline character, it computes how much whitespace follows it. It then consults the indentation stack. If the whitespace just scanned represents a larger indent than that which is on the parsing stack, you push and remember to emit an INDENT token. If it's less than the top elemen
<discocaml_>
<psychokitty> I explain this not because it's particularly relevant to OCaml or whatever, but because you can see it's a pain regardless.
<discocaml_>
<psychokitty> I've found one solution on GitHub that's rather involved. Seems a decision between two evils whichever way you cut it.
<discocaml_>
<psychokitty> So, the "modes" of more lex-esque implementations of lexer generators allow the lexer to complete a semantic action and immediately go into another mode. Whereas, mutually recursive rules (as in ocamllex) kind of expect to complete some work and return back.
<discocaml_>
<Bozhidar> Is there any timeline for OCaml 5.1? I see that the list of changes after 5.0 is pretty big already (see https://github.com/ocaml/ocaml/blob/trunk/Changes), so I was wondering if there are any plans for 5.1 already. Lots of interesting changes coming.
<discocaml_>
<NULL> If you allow a `DEDENT n` token, it seems rather fine, no?
<discocaml_>
<psychokitty> Yeah, so I did that (expecting, later to basically preprocess the fully lexed file) and then feed an expanded version to menhir. The issue is that the dedents need to appear _after_ the newline.
<discocaml_>
<psychokitty> So, my understanding is that I'd need a way to be able to invoke another rule in an ocamllex action, then emit two tokens.
<discocaml_>
<psychokitty> The "rather involved" solution I speak of on GitHub yields lists of tokens from ocamllex to deal with this.
mro has joined #ocaml
<discocaml_>
<psychokitty> So, my understanding is that I'd need a way to be able to invoke another rule in an ocamllex action, then emit two tokens (and, if I can emit two tokens, why not `n` + 1 tokens for a `DEDENT n`).
<discocaml_>
<psychokitty> I've actually kind of shelved this for now, resolving to just write a handwritten lexer if I get back around to it. Although, I do wonder if it's really so bad producing lists from the lexer and then feeding menhir the individual sublists' tokens.
<discocaml_>
<psychokitty> Oh, yeah, the solution I gave of yielding two tokens (newline + indent/dedent) would also need to advance the internal lex buffer beyond the whitespace for the next munch, so it still suffers from that limitation.
<discocaml_>
<NULL> There's another slightly ugly solution which is to shadow your entry point into a function which stores its state (and as such tokens to return before calling the main function)
bartholin has joined #ocaml
bartholin has quit [Quit: Leaving]
olle has joined #ocaml
Tuplanolla has joined #ocaml
wingsorc has quit [Ping timeout: 246 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
azimut has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
amk has quit [Remote host closed the connection]
amk has joined #ocaml
mro has joined #ocaml
Serpent7776 has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<discocaml_>
<lukstafi> Does anyone recall discussions of a `Typedtree` pass for PPX? I'm asking in the context of the sorry state of OCaml debugger. Hoping for `[%debug_this ...]` expressions that print the state of the local environment.
<discocaml_>
<octachron> This is mostly a dead-end. Types don't exist at runtime, your `[%debug_this ... ]` function cannot work on any polymorphic functions.
<companion_cube>
The debugger is also a bit of a dead end, sadly, so we don't have any good solution
<discocaml_>
<lukstafi> My `[%debug_this ...]` function would only exist at compile time. At runtime, there would only be `printf` statements.
<discocaml_>
<lukstafi> I don't accept this answer. I don't want to live in the dark ages anymore (after writing some code in Python and TypeScript). Maybe I try resurrecting `ocamlearlybird`...
<discocaml_>
<octachron> @lukstafi , you don't have the information to have accurate `printf` calls at compile time.
<discocaml_>
<octachron> OCaml is a functional language, you cannot assume that all functions are monomorphic.
<discocaml_>
<lukstafi> What about at the time `Typedtree`s are constructed? In any case, if Merlin can know the types, they must exist.
<discocaml_>
<lukstafi> Monomorphic and single-threaded is good enough for debugging conceptual issues. (That's my use-case, not tricky code fortunately.)
<discocaml_>
<octachron> Merlin knows the type schemes.
<discocaml_>
<octachron> Sure, you can have a debug printer for monomorphic functions but then:
<discocaml_>
<octachron> - users can call the printer with the type too
<discocaml_>
<octachron> - you are covering a small part of the language without any possibility of evolution, aka a dead end.
<companion_cube>
What is the non dead end solution? Dwarf support?
<discocaml_>
<octachron> Corrections with monomorphic functions with no abstract types without an exported printer.
<discocaml_>
<octachron> Probably, dwarf support with exported runtime type information in the native compiler.
<discocaml_>
<octachron> Maybe dead-end is a bit too strong. Maybe more `local maximum with no path forward toward the global maximum`.
<discocaml_>
<dariusf> you could try https://github.com/dariusf/ppx_debug, it does what you're describing by getting the types from cmt files during the build. But yes it doesn't work with polymorphic functions and expects that printers are available and follow certain conventions
<discocaml_>
<dariusf> Just curious, what do you think about ocamldebug, is there a path forward by improving it?
<discocaml_>
<lukstafi> Thank you, I wasn't aware of it! Helpful! (Should have googled, dang.)
<discocaml_>
<octachron> Possibly? At the very least, I have the impression that there is room for improving ocamldebug tool integration and user experience? And it is not clear to me if such improvement could be transferred or not to an eventual native debugger.
<companion_cube>
As long as ocamldebug is stuck in bytecode only, imho, it'll remain of very limited usefulness.
<companion_cube>
Being compatible with gdb, rr, etc would be immensely better
<discocaml_>
<lukstafi> If something like `ocamlearlybird` worked out of the box, I would mock the parts of my program that require to be run natively, for debugging.
<discocaml_>
<NULL> I wouldn't be so sure; how often do programs need to run natively, how many people want compatibility with other languages' tools ?
<companion_cube>
Hmmm, everyone? :D
<discocaml_>
<NULL> I can at least tell you I don't
<companion_cube>
Everyone compiles to native, afaik. And basically anyone who comes to ocaml from another language will expect gdb/lldb to work
<discocaml_>
<NULL> I don't "compile to native", I run dune
<companion_cube>
Ofc we're so used to not having a working debugger that we don't see it this way
<companion_cube>
Dune will run in native mode by default...
<discocaml_>
<NULL> If dune provides debuggable compiled files with a flag, that's good enough for me
<discocaml_>
<masterbuilder> I was not expecting gdb to really work at all so I think what is available already is a good start, not really fully usable yet though
<companion_cube>
Bytecode doesn't even have consistently good stack traces
<discocaml_>
<NULL> (Does dune build compile to native ?)
<companion_cube>
Yes
<companion_cube>
Of course it does :/
<discocaml_>
<masterbuilder> there is a flag you must set to enable bytecode compilation
<companion_cube>
It'd be pretty useless otherwise
<discocaml_>
<masterbuilder> or configuration option rather
<discocaml_>
<NULL> That tells how much I care of the compilation mode
<discocaml_>
<lukstafi> @dariusf is there a roadmap to get `ppx_debug` to `opam`? If I could help, I think I could find some time.
<discocaml_>
<lukstafi> @dariusf is there a roadmap to get `ppx_debug` to `opam`? (ETA: I mean to the public repository.) If I could help, I think I could find some time.
<discocaml_>
<dariusf> not atm. it was more of a proof of concept, and i haven't found anyone else wanting to use it for real yet 😄
<companion_cube>
@NULL if it was bytecode, you'd heard dozens of times "careful, use such and such flag to get decent perf"
<discocaml_>
<NULL> What's the difference when `--profile=release` then ? Is it just that warnings aren't considered errors ?
<zozozo>
@NULL iirc, in the dev profile, things are compiled with opaque to limit cross-module optimisations so as to make compiling things faster
<companion_cube>
Release will enable cross module inlining and so on, at the price of slower compilation and worse modular compilation (ie changing a module will sometimes recompile the module's dependents)
<discocaml_>
<dariusf> is performance the main problem with bytecode?
<companion_cube>
So it's better, but afaict the gap between bytecode and native is generally a lot wider
<companion_cube>
Especially since there are few optimizations with bytecode
<discocaml_>
<dariusf> seems like that could be somewhat mitigated by mocking as @lukstafi said. though i agree having to modify code to debug it is a pain
Haudegen has joined #ocaml
John_Ivan_ has joined #ocaml
rf has joined #ocaml
<discocaml_>
<lukstafi> `ppx_debug` is great! (At least on paper, I'm having some build issues.) It has to be better advertised!
jao has joined #ocaml
sagax has joined #ocaml
spip has joined #ocaml
bobo_ has quit [Ping timeout: 252 seconds]
olle has quit [Remote host closed the connection]
<discocaml_>
<Alistair> OCaml meetup in london when?
<discocaml_>
<Alistair> (In all seriousness I'd love to help organise some form of OCaml meetup in London -- perhaps we can get some help from some of the London-based OCaml companies like JS / TriliTech / Meta?)
<Armael>
you could also contact the ocaml fundation, I think they have funding for that kind of things
mro has quit [Remote host closed the connection]
azimut has quit [Ping timeout: 255 seconds]
John_Ivan_ has quit [Read error: Connection reset by peer]