Giter VIP home page Giter VIP logo

Comments (6)

Chris00 avatar Chris00 commented on August 13, 2024

I cannot reproduce your problem:

# let x = 12;;

print_endline "hello word!";;
val x : int = 12
#   hello word!
- : unit = ()

from tuareg.

brabalan avatar brabalan commented on August 13, 2024

I'm trying to debug this and here is what I see. The problem is that tuareg--beginning-of-phrase goes too far back.

The first iteration of smie-backward-sexp returns (18 11 ";;") and the point is at the beginning of print_endline. Since no condition applies (";;" is not in tuareg-beginning-of-phrase-syms, the return is not null, the first element is a number), then another iteration happens and the point goes to the first let, which is then executed.

from tuareg.

Chris00 avatar Chris00 commented on August 13, 2024

Now that I understood what your report is about, I am less keen to fix this one. IMHO, code in a file should not use ;; to delimit phrases — or rather, they can be present but the code should compile if they are all removed.

from tuareg.

brabalan avatar brabalan commented on August 13, 2024

Since this is in the context of teaching I'm trying to follow rigorous rules, such as http://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Usingandomittingand
In particular, I try to minimize the difference between using the toplevel and using a file.

Here is a related bug, but without ";;". When evaluating the code

print_endline "hello world!"

let x = 5

with the point on the first line, and doing C-x C-e, the point ends up at the beginning of the quotes instead of the beginning of the let on the next line. So doing C-x C-e again does not evaluate the next phrase.

from tuareg.

Chris00 avatar Chris00 commented on August 13, 2024

IMHO, the rules given at http://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html#Usingandomittingand are overly complicated and that section should be rewritten. The first answer to “When should you use ;;” should be to mark the end of an entry to the toploop — and then one may go on explaining that it may sometimes be useful in code files too (but not to avoid executable blocks).

from tuareg.

brabalan avatar brabalan commented on August 13, 2024

I just noticed this has been fixed. Thanks!

from tuareg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.