mwatts15 / crono Goto Github PK
View Code? Open in Web Editor NEWScheme project for CS345
Scheme project for CS345
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.
Partial function application a la Haskell.
curry
procedure MAY be provided((\ (x y) (+ x y)) 4)
(\ (y) (+ 4 y))
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?
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.
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)))
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.
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()
Make this work
(let ((f (lambda (x) (if (= x 0) 0 (+ (f (- x 1))))))))
The StringBuilder can get initialized with a negative index.
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).
Is there a reason for functions to take argument arrays rather lists?
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.
We need to build the AST such that it can be visited by a Visitor class.
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?
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 similar to C structs.
(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))
CronoFunctions have a separate process for evaluation which makes processing them like other functions (using closures and currying) difficult.
I wasn't able to build crono using ant from the crono.zip on the UTCS machines.
(functor argument1 argument2 ... argumentN)
(rule (predicate predicate1 predicate 2 ... predicateN))
(Refer to Racklog. I want to make ours a little less verbose, but probably with similar internals.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.