Code Monkey home page Code Monkey logo

crono's People

Watchers

 avatar

crono's Issues

Reduce the number of core functions

We can reduce the number of core functions by removing redundant ones (like GT and LT, ADD and SUB, even MUL and DIV since their implementations are based closely on Java's). The functionality can be added back with a surface layer that translates to the core. The surface layer should probably be added in Java for the sake of providing reasonable traces, but it might be fine to do in Prelude instead.

Add function currying

Description

Partial function application a la Haskell.

Requirements

  1. SHOULD NOT require extra function calls or special syntax like (curry function arguments)
    • However, an explicit curry procedure MAY be provided
  2. SHOULD be done implicitly
  3. A curried procedure should be internally the same as a closure with values filled in for the arguments it was applied to.

Example

((\ (x y) (+ x y)) 4)
    (\ (y) (+ 4 y))

Syntax for define

Currently, using the define function is identical to using a lambda, except that it places the lambda inside the environment. This causes an issue with creating and inserting structs into the environment. This could be fixed by changing the struct functions to all place the structs inside the environment, however it is also possible to create a more general fix to this.
If we change the syntax for define from:

(define *name* (*args*) (*body*))

to:

(define *name* *cronotype*)

it would allow us to place arbitrary symbols in the environment. For example, it would be possible to define Pi as:

(define m_pi 3.141592654)

It would make creating structs easier:

(define student1 (newstudent Student))

And it would still be possible to place lambdas in the environment:

(define do_something (/ (x y) (+ x y)))

Should I change the way define is defined in CronoFunctions to do this?

Foldr using list combinators

This issue depends on Issue #5.
The project requirements state that we need to have foldr implemented using list combinators. Currently it is implemented using car and cdr.

Bug with Structures in Lists.

There is a bug with the current way structs are handled; consider the following scenario:

(print (struct1, struct2, struct3))

where struct1, struct2, and struct3 are all symbols pointing to structures. The intended behavior is to
have the print function print out a cons with the string representation of each of the structs. However, since each of the structs is also technically a function, Crono will interpret the cons as a function application and throw a runtime exception since the second and third arguments are "wrong". Quoting the cons won't work, since Crono won't attempt to resolve the symbols and you will get the literal string "(struct1, struct2, struct3)".
This doesn't just affect the print function; any time you wish to pass a cons of structures to a function it will break. Currently the only method is to use the cons function:

(define structlist (cons struct1 (cons struct2 (cons struct3 Nil))))
(print structlist)

While this works, it breaks the intuitive flow of allowing list definitions since

(print (1 2 3))

will work in the current interpreter.

Any ideas on what we should do? It would be possible to add another exception to the Interpreter that gets checked when the arguments are wrong to a function. It would also be completely possible to have a 'resolve' function which translates symbols to their definitions and nothing else; eg:

(print (resolve (struct1 struct2 struct3)))

Fix lets returning functions being evaluated(?)

Currently, the example given in the project requirements handout states that the code:

((let ((f (\ (x) x))) f) (let ((x 4)) x))

should evaluate fine, with a result of 4. However, the interpreter currently does not evaluate this, instead throwing an InterpreterException with the message

Invalid Function Application: 4 is not a function in (4)

We need to get this statement working properly before Thursday.

Leaking definitions

Definitions are being lost during interpretation:

(markw@envy)(zsh:2)(/v/filer4b/v38q001/markw/cs345/proj/crono)
(1160)% ./crono.sh -T                                                                                        23:38
Crono++ by Mark Watts, Carlo Vidal, Troy Varney (c) 2012

> (load "prelude.lisp")
Visiting (load prelude.lisp)
  Visiting load
    Result: load
  Visiting prelude.lisp
    Result: prelude.lisp
  Result: #t
Result: #t
> (prFoldr + 1 '(1 2 3))
Visiting (prFoldr + 1 '(1 2 3))
  Visiting prFoldr
    Result: (\ (fn z x) (<Y> (<B> (<COND> (= Nil) (<K> z)) (<B> (<S> (<B> fn (car))) (<C> <B> cdr))) x))
  Visiting +
    Result: +
  Visiting 1
    Result: 1
  Visiting '(1 2 3)
  Visiting (1 2 3)
    Result: (1 2 3)
    Result: (1 2 3)
Invalid Function Application: g is not a function in (g x)
vvvvvvvvvHEREvvvvvvvvvv
> (prFoldr + 1 '(1 2 3))
Invalid Function Application: prFoldr is not a function in (prFoldr + 1 '(1 2 3))
^^^^^^^^^^^^^^^^^^^^^^^^^
> 

and even more disturbing

> (+ 2 3)
Result: (+ 2 3)
> (+ 2 3 4)
Too many arguments to +: 3/2 recieved
> (+ 2 3)
Result: (+ 2 3)
>

First guess is unmatched push/popEnv()

AST Branch Merge

Did we decide to merge the tvarney-ast branch into the master branch? If so how should we go about it? I know that Mark didn't like that there were a few rather monolithic commits in the branch, but I can't figure out how to split them apart. Also, I've added things to that branch that we should probably go over before merging (packages and the quote node).

Add Environment Printout

The project requirements for this are:

The interpreter should build an Environment that prints out like FAE but with lisp/scheme syntax.

This should be simple to do, but the syntax of the environment printout is iffy.
Should we go with:

(let ((sym value) ...))

as the full environment printout, or should we attempt to do nesting such as:

(let ((sym value)) (let ((sym value)) ... ))

It would be easier to do the former, and just as correct as the latter.

Build the AST

We need to build the AST such that it can be visited by a Visitor class.

Proper strings

Strings are partially implemented, but the interpreter still tries to use them as functions.

From what I understand, the characters in the cons created are of type CronoCharacter.
The simplest fix I can think of would be to tell the interpreter to skip evaluation of lists starting with CronoCharacters.

Would this be feasible?

Create exception classes

It might be cleaner to create classes for type errors and other runtime exceptions rather than just passing a format string. Opinions?

Add structures to Crono.

Description

Add structures to Crono similar to C structs.

Requirements

  1. Support for defining new structures
  2. Support for creating new instances of a structure.
  3. Getting and Setting fields from the structure.
  4. Default arguments for fields should be able to be given in the structure definition.
  5. Allow structs to extend other structs.

Example

(struct Person (name gender age))
(substruct Employee Person (position (wage 7.25) boss))
(let troy (newstruct Employee
    ((name "Troy")
     (gender "Male")
     (age 21)
     (position "Software Engineer")
     (wage 20.25)
     (boss "Alex"))
(troy name))

Add Prolog style database queries

Requirements

  1. Predicates SHOULD use the form (functor argument1 argument2 ... argumentN)
  2. Rules SHOULD use the form (rule (predicate predicate1 predicate 2 ... predicateN))

(Refer to Racklog. I want to make ours a little less verbose, but probably with similar internals.)

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.