Code Monkey home page Code Monkey logo

lamb's People

Contributors

zij-it avatar

Stargazers

 avatar

Watchers

 avatar  avatar

lamb's Issues

GC never frees

The garbage collector is currently really just a garbage tracker. It doesn't do anything with the garbage, and just holds it in a nice little list.

Similar to the original C++ version, it is going to be a mark and sweep GC. The first implementation should not use unsafe.

Patterns: Cannot match on a negative number

Currently the following results in a parsing error:

>>> case x {
>>>     -1 -> 1,
>>>     1 -> -1,
>>> }
>>>
Error: [Lamb] Syntax Errors:
   ╭─[repl:1:1]
   │
 3 │     -1 -> 1,
   │     ┬  
   │     ╰── Unexpected item: '-'
───╯

This is because -1 is parsed as the positive number 1 preceded by the unary minus. Currently only patterns can be parsed on the left side, and such an operation is not allowed in a pattern.

Running `blocks.lb` results in type error

More specifically, the following line results in a type error:

println(if false { 1 } elif true { 2 } else { 3 });

It appears as though the false is not popped off of the stack before entering the elif body, thus resulting in the VM seeing an attempt to call the value false with the argument 2.


Sidenote: I really need to go through and verify that all the examples are able to run, or modify them to make sure that they run.

Then I need to set up a way to test each one so that branches can't be merged onto main without verifying that the examples are able to run successfully

REPL Behavior

The REPL waits for the entire input before evaluating anything, so it's not possible to use the repl to evaluate expressions like:

>>> 2 + 2

If the user presses <ENTER> at this point, a new line is created, and nothing is evaluated. If the user attempts to evaluate this expression, it fails with a syntax error because the REPL only reads statements. Thus, the following changes are desired:

  • The user should be able to enter an expression or a statement into the REPL:
    • if expr => Wrap the expression in a println call and evaluate as if println expr-statement.
    • if stmt => Evaluate the statement
  • The REPL should support history and history navigation
  • The REPL should support moving around the input with arrows

Running `fail.lb` results in type error

A minified version of the problem is this:

{ 
  id := fn(x) -> x;
  1 $> id .> { x := id; x } .> { y := id; y }; 
}

I assume it's because compiling .> doesn't handle adding a dummy local to the stack

Patterns: All patterns not required to bind ident

It should be required that all patterns in a series bind the same identifiers. This means that the following should fail to compile because the left pattern is missing the binding b and the right pattern is missing the binding a.

case x {
   a @ 1 | b @ 2 -> a,
}

This should be caught by a step in between parsing and execution.

Doubles never lexed / parsed

Although it was intended that they are supported, neither the lexer nor the parser support floating point numbers. Thus the following leads to a syntax error:

123.123;

Unsafe Optimization - GC

The GC could be optimized to instead use the format like in the previous C++ version, meaning that instead of using a hashmap-like impl for the allocations we can instead use the linked-list with raw pointers.

This would also allow for the VM to store a pointer to the Chunk within the loop, meaning that self.chunk() can be reduced to (*current_chunk).

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.