Giter Site home page Giter Site logo

blueprint's People

Contributors

hrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blueprint's Issues

Implement destructuring-bind

It'd be slick if we could perform a destructuring-bind when binding variables. Something like:

(destructuring-bind (a (b c) d) '(1 (2 3) 4)
    (list a b c d)) # => '(1 2 3 4)

I think §18 of On Lisp has some good stuff on destructuring. We could probably implement this as a macro in the standard library.

REPL should be able to handle multiple lines of input

Right now, if we try to enter a multi-line expression on the REPL, it'll throw an error and exit. Instead, we should catch those errors (where appropriate) and let the user keep typing on the next line.

We could also try to determine if an expression is balanced and use that information instead. What do other lisps do?

Implement macroexpansion as a separate phase?

Pros:

  • Pulls functionality out of the evaluator.
  • Probably improves evaluator performance.
  • Establishes precedent for building other phases (replacing constants, various optimizations).

Cons:

  • Introducing a compile-time/runtime distinction, which is arguably harder to reason about (especially as it relates to loading). Probably need to check Flatt 2002.
  • Need to implement a load phase, too, since we want to be able to expand macros in other files.
  • If we want macros to remain applicable we'll need to pass the Macro objects from the expander to the evaluator, which means the evaluator won't be any simpler.

Add note that Blueprint macros are fexprs

The terms that Blueprint calls macros are expanded at runtime (rather than in a separate macro-expansion phase). It's not exactly wrong to call them macros, but the more precise term would be "fexprs," and we should refer to them as such in the documentation.

On the topic of fexprs, Kent Pitman wrote Special Forms in Lisp in 1980 recommending against their use because they aren't amenable to static analysis. Blueprint performs exactly no static analysis, and doesn't aspire to, so this isn't a big problem for us. It's something to consider for future languages, though!

Fix comments

They're totally broken right now. Our parser tests need to be a lot more extensive.

Reimplement the standard library in actual Blueprint

Right now the standard library is basically a collection of raw ASTs, but there's nothing conceptually stopping us from reimplementing it in Blueprint itself. This will require:

  • The ability to read and evaluate a file (where the standard library will live).
  • A mechanism for defining macros in Blueprint for let, etc (as described in #9)

Add macro literals

We've got function literals in the form of lambdas, and macros are essentially a first-class object in Blueprint anyway, so maybe we should add a syntax to create anonymous macros?

Add user-defined macros

Through a defmacro special form, or something similar. I'd like to match the syntax up with the Scheme-style define I'm already using, so we'll want something like:

(defmacro (if condition consequent alternative)
  `(cond (,condition ,consequent)
         (else ,alternative)))

If we're still using chunkier syntax (macro-quote, macro-escape, macro-splice, or whatever) instead of backquotes and commas, then that's just fine, too.

Add macro-quote, macro-escape, and macro-splice special forms

We need forms that serve the purpose of backquote, comma, and ,@ in Common Lisp.

We'll eventually want to add the fancy syntax for them in the parser (or as reader macros, if I ever figure out how those work...) but in the meantime these'll do. Anything beats manually cobbling together macros with list and quote.

Define variadic functions

Standard Scheme uses a dot notation to define functions that take a varying number of arguments:

(define (my-function (a b . the-rest)
  ...)

We'll need to tell the parser to accept dots and modify lambda and define to handle this.

Make special forms applicable

It's be cool if we could write something like:

(map first '((1 2) (3 4)))

Right now we can't, since first is a special form. We have to do something like this instead:

(map (lambda (x) (first x)) '((1 2) (3 4)))

Which is kinda lame.

Support comments

I think I prefer # to end-of-line style syntax, like in shell/Perl/Python/Ruby/etc.

let shouldn't be a special form

let is currently handled in eval, which isn't right. It should be a macro which is expanded as part of a general macro-expansion step between parsing and evaluation.

Refactor to objects

The whole Evaluator class is a big mess! It'd be much better if each kind of node in the AST was its own class with an eval function that took an environment and returned an expression and a possibly-updated environment.

Curried functions?

I'm not sure how hard this would be, or how difficult it would be to integrate with the pattern-matching function arguments discussed in #31. But it'd sure be neat.

Define set! and define as special forms

They're not currently defined, but they're pretty important.

We might also consider defining define as a macro that uses set!. Gonna have to look into it once we've got macro-expansion.

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.