Friday, November 18, 2011

Google's Go

While playing with Google's Go programming language, I discovered that it properly traps stack overflows.  A basic concept for a compiler, but interesting to play with from a web browser (  This led me to wonder how complex of a stack could be built and properly trapped.  

The following code fails to execute via the browser as it consumes too much memory, but I wonder how it would normally be handled and it would be interesting to see a trace of the execution.

package main
func a(x int) {
  if x==1 {b(2)}
  if x==4 {c(5)}
  if x==8 {b(9)}
  if x==12 {b(13)}
  if x==15 {b(16)}
  if x==17 {c(18)}
func b(x int) {
  if x==2 {c(3)}
  if x==6 {c(7)}
  if x==9 {c(10)}
  if x==11 {a(12)}
  if x==13 {c(14)}
  if x==16 {a(17)}
func c(x int) {
  if x==3 {a(4)}
  if x==5 {b(6)}
  if x==7 {a(8)}
  if x==10 {b(11)}
  if x==14 {a(15)}
  if x==18 {a(1)}
func main() {

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.