Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix doc, clean-up some TODOs that are now open issues

  • Loading branch information...
mna committed Oct 5, 2013
1 parent f086e12 commit ff78c214236f548791478283407903e40f27ee19
@@ -191,9 +191,8 @@ func TestEmit(t *testing.T) {
}
}

// TODO : Duplicate from decode_test.go in bytecode package, cannot put it in
// bytecode/testing because it would need circular reference.
// But different equal checks, here I don't care about Header and such
// Duplicate from decode_test.go in bytecode package, but different
// equal checks, here I don't care about Header and such
func equal(c int, f1, f2 *bytecode.File) bool {
if f1 == nil && f2 == nil {
return true
@@ -278,8 +278,6 @@ func (p *Parser) assignment(id string) *Symbol {
})
}

// TODO : For now, it doesn't support a list of vars followed by a
// matching list of expressions (a, b, c := 1, 2, 3)
func (p *Parser) define(id string) *Symbol {
return p.infixr(id, 10, func(sym, left *Symbol) *Symbol {
if left.Ar != ArName {
@@ -36,7 +36,7 @@ b := 10
add := a + b
sub := a - b
mul := a * b
div := a / b // TODO : Should div return a float even for Int?
div := a / b
mod := b % a
not := !a
unm := -a
@@ -32,7 +32,7 @@ b := 10
add := a + b
sub := a - b
mul := a * b
div := a / b // TODO : Should div return a float even for Int?
div := a / b // Comment
mod := b % a
not := !a
unm := -a`),
@@ -46,15 +46,15 @@ Agora is syntactically very similar to Go. But its goal is obviously not to be a

* The `panic` built-in function takes a value and raises an error with it. However, it *doesn't* raise if the value is falsy. This is symmetric with the behaviour of `recover`.

* The `recover` built-in function takes a function as parameter, and executes it in protected mode. By default, a runtime error is a panic, and stops all agora code execution to return the error to the Go host program (the second value returned from `module.Run()`). To *catch* errors in agora code, the `recover` function must be used, this is what is called the protected mode (similar to Lua error handling). `recover` runs the provided function, and if an error occurs, it catches it and returns it. Otherwise it returns `nil`.
* The `recover` built-in function takes a function as parameter, and executes it in protected mode. By default, a runtime error is a panic, and stops all agora code execution to return the error to the Go host program (the second value returned from `module.Run()`). To *catch* errors in agora code, the `recover` function must be used, this is what is called the protected mode (similar to Lua error handling). `recover` runs the provided function, and if an error occurs, it catches it and returns it. Otherwise it returns `nil` (see /testdata/src/42-recover-ex.agora for an example).

* Field access can *also* be done using an array-like syntax, `object["key"] = value`. Any type except `nil` can be used as the key, and when assigning to a field using the `.` operator, the key is implicitly a string (denoted by the identifier of the field), so `object.key` is equivalent to `object["key"]`.

* There are no bitwise operators.

* There is no multi-thread (goroutine) or channel support. Agora code must be single-threaded, although different execution contexts *can* be run in parallel.
* There is no goroutine or channel support. Agora code must be single-threaded, although different execution contexts *can* be run in parallel.

* Although there are no goroutines, agora supports *coroutines*, cooperative multi-threading. Any agora function can use the `yield` keyword to return a value, and may continue after the `yield` with a subsequent call.
* Although there are no goroutines, agora supports *coroutines*, cooperative multitasking. Any agora function can use the `yield` keyword to return a value, and may continue after the `yield` with a subsequent call (see /testdata/src/68-cons-prod.agora for a consumer-producer example using coroutines).

* There are no slices or maps, the only compound data structure is the object. It can represent a slice and a map, and eventually will be optimized for when used as a slice/array.

@@ -126,8 +126,6 @@ func (c *Ctx) Load(id string) (Module, error) {
// If already bytecode, just decode
var f *bytecode.File
if rs, ok := r.(io.ReadSeeker); ok && bytecode.IsBytecode(rs) {
// TODO : Eventually come up with a better solution, or at least a
// failover if r is not a ReadSeeker.
dec := bytecode.NewDecoder(r)
f, err = dec.Decode()
} else {
@@ -80,7 +80,6 @@ func (a *agoraFuncVal) Call(this Val, args ...Val) Val {
vm = newFuncVM(a)
}
// Set the `this` each time, the same value may have been assigned to an object and called
// TODO : Is this the desired behaviour?
vm.this = this
a.ctx.pushFn(a, vm)
defer a.ctx.popFn()
@@ -296,8 +296,6 @@ func (vm *funcVM) pushRange(args ...Val) {
panic(NewTypeError(t, "", "range"))
}
if vm.rsp == len(vm.rstack) {
// TODO : Compile and store required rstack size in bytecode, so that
// it doesn't need to expand?
if vm.debug && vm.rsp == cap(vm.rstack) {
fmt.Fprintf(vm.proto.ctx.Stdout, "DEBUG expanding range stack of func %s, current size: %d\n", vm.val.name, len(vm.rstack))
}

0 comments on commit ff78c21

Please sign in to comment.
You can’t perform that action at this time.