Skip to content

Latest commit

 

History

History
217 lines (177 loc) · 5.59 KB

File metadata and controls

217 lines (177 loc) · 5.59 KB

Notes

Todos

Reader Environment

Keeps track of:

  • Reader state:
    • Position
    • Errors
    • Reader Macros
    • Readtable

Analyzer Environment

Keeps track of:

  • Analyzer state:
    • Identifer bindings
    • Import paths (do when needed)
    • Errors

analyze()

get rid of string cloning at some point

  • 1st upgrade: Rc<str>
  • 2nd: Cow<str> or custom indexing (no lifetimes required, I think)

Bytecode

Major features

Reader

Consumes a text stream, produces a form.

Reader macros

Forms

Untyped syntax tree, essentially.

Need to figure out what the fundamental variants here are.

Forms should provide span information, for compiler messages.

Possibly / Probably:

ListSequence of forms.
Atom

Clojure’s model:

(def eval [form]
  (-> form
      macroexpand
      analyze
      execute)) ;; emit, etc.

Macros

Analyzer

Takes in a form, produces a typed AST.

Wait, do macros need to be type checked before expansion? (probably, right?)

AST

Type system

Kinds of type constructors

Forms a regular langauge of types.

Nullary

Language primitives, the base alphabet Σ of the type langauge, the terminal symbols of it’s grammar.

The user cannot create new types of this family.

Unary

  • Kleen Star

N-ary

  • Sum
  • Product

Types of types

Form concrete strings in the type language.

(TODO: thus the Kleen star is not present, correct?)

Primitive

Record

Union

Inference

Global (+ some boundaries? At least by convention?).

Need to work out unification rules for axiomatic constructs. Pay attention to hazards outlined here. (find better/more resources)

Things to think about

Use fibers/coroutines when evaulating arbitrary (non-totality checked) code at compile time, such as reader macros, EPEG rewriters, constant functions, etc. That keeps any non-terminating code from blocking the compiler, and doesn’t require bailing out at an arbitrary timeout. Perhaps have some kind of ease-off (like in CAS loops) for when computations start taking too long, as it’s more likely they won’t terminate and we want to waste as little time as possible. Perhaps have a priority order for incremental computations that are making progress vs. ones that aren’t making observable progress.

Macros vs. Compiler Macros (interception)

Effects

Including parametricity over effects

Default arguments, default types

Types: (rust-y syntax) Result<T, E = Error>

Creates Result<T> and Result<T, E>

Typed macros

How do they work? How do they interact with other features?

HKTs

” ”

Typeclasses vs. ML Modules

What is necessary for the interpreter?

Start laying out a high-level design

;; how do namespaces/modules fit into this?
(-> String
  InputStream
  Form
  AST

Namespaces

Server

Functions

exposed to client

new-session
Begins a new session. Server returns session token?
Protocol

Header

requestresponse
formatformat
u8u8

Glossary

form
(needs revision) A list, identifier, or a number.

What else? Is this a bounded category?

Is there a ‘generalized object’ type of form?

read
Function that deserializes an object/form from a text stream.
eval
Evalutates an object/form.

General notes

The symbol table primarily facilitatesthe replacement of identifiers in the program with a primary key.

http://www.slideshare.net/Tech_MX/symbol-table-design-compiler-construction

AST - lexical; program elements referred to by textual name. ASG - “semantic”; program elements referred to by unique key.

  • Be able to pass a closure to assert to do something other than panic on failure

Library ideas

Auto Refactor

Use eqsat or something to shorten/idiomaticize source code

Error resolution suggestion/completion

Visual REPL extensions

SQL DSL/Parser

Infix math

equivalent to call-haskell-from-anything

code manipulation tooling

Will involve some pretty-printing

  • syntax highlighting
  • formatter
  • error/warning reporting
  • (symbols in scope/variants & methods of type) for autocomplete
  • extensibilty system for this (i.e. plugins)
  • create aliases for overloaded function variants
  • documentation search engine
    • Limit by scope (current ns, std lib, imported libs, etc.)
    • Search item desctiptions as well as names and types
  • fuzzy expression-shape searching

literate programming

Polymorphic on host markup language?

Coroutines, stack(ful/less)

async/await

whole alternate syntaxes (and conversions to/from?)


macros

KWargs
(kw the-func map-or-struct-or-arg-pairs)
where clause
Desugars to a let. (would have to be a reader macro, no?)
(+ a b c
  where a 3
        b 2
        c (* a b))

macros to copy-with-modification existing code

  • Add/change variants to type
  • similar with namespaces
  • memotize a function
  • make a recursive function use iteration+heap

module dependancy graph creation

Perhaps a generalized dependancy graph module?

pretty printing

Include incorporation of formatting info? (e.g. [color, style] spans?)

  • code
  • tables
  • graphs

Additive graph-based flowchart knowledgebase

Ask user a question at each node, their answer directs them to a child. New answers can be added to the graph.