Skip to content

Commit

Permalink
Updated README.markdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Suraci committed Dec 8, 2009
1 parent ed938a7 commit 8b44a01
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
57 changes: 41 additions & 16 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ Example session:
Enter '?' for a list of commands.
> ?
Commands:
?: help
+ (pkgname): import package
-[dpc]: pop last (declaration|package|code)
~: reset
: (expr): add persistent code
!: inspect source
> println(1 + 2)
3
? help
+ (pkg) import package
- (pkg) remove package
-[dpc] pop last (declaration|package|code)
~ reset
: (...) add persistent code
! inspect source
> a := 6
> b := 7
> println(a * b)
Expand All @@ -26,14 +25,16 @@ Example session:
! fmt> fmt.Println("Hello, world!")
Hello, world!
! fmt> println("This won't work since fmt doesn't get used.")
! fmt> : fmt.Print("")
Compile error: /tmp/gorepl.go:2: imported and not used: fmt

! fmt> : fmt.Print()
fmt> println("Now it will!")
Now it will!
fmt> func b(a interface{}) { fmt.Printf("You passed: %#v\n", a); }
fmt> func b(a interface{}) { fmt.Printf("You passed: %#v\n", a); }
fmt> b(1)
Compile error: /tmp/gorepl.go:12: cannot call non-function b (type int)
! fmt> !
Compile error: /tmp/gorepl.go:14: cannot call non-function b (type int)

fmt> !
package main
import "fmt"

Expand All @@ -46,11 +47,35 @@ Example session:
noop(a);
b := 7;
noop(b);
fmt.Print("");
fmt.Print();
}

fmt> -d
fmt> !
package main
import "fmt"

func noop(_ interface{}) {}

func main() {
a := 6;
noop(a);
b := 7;
noop(b);
fmt.Print();
}

! fmt> -d
fmt> func dump(a interface{}) { fmt.Printf("You passed: %#v\n", a); }
fmt> dump("Phew, there we go.")
You passed: "Phew, there we go."
fmt>
fmt> -d
fmt> -c
! fmt> - fmt
> + math
! math> println(math.Pi)
+3.141593e+000
! math> + fmt
! math fmt> fmt.Println(math.Pi)
3.1415927
! math fmt>

5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,12 @@ func main() {

switch v.(type) {
case *ast.AssignStmt:
w.code.Push(v)
w.code.Push(v);
changed = true;
default:
w.exec = str.String()
}
}

changed = true
case []ast.Decl:
for _, v := range tree.([]ast.Decl) {
str := new(bytes.Buffer);
Expand Down

0 comments on commit 8b44a01

Please sign in to comment.