Skip to content

Instantly share code, notes, and snippets.

@hostilefork
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hostilefork/633fb901da08c223b900 to your computer and use it in GitHub Desktop.
Save hostilefork/633fb901da08c223b900 to your computer and use it in GitHub Desktop.
Simple reduce case for Red Issue #941 (with full debug verbosity in interpreter.reds)
;; https://github.com/red/red/issues/941
red>> foo: function [] [a: 10 b: 20 return [a b]]
== func [/local a b][a: 10 b: 20 return [a b]]
red>> reduce foo
;-- skip console boilerplate head code
eval: action/native return type: 2
eval: root loop...
eval: fetching value of type 20
eval: path
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 12
eval: spec entry type: 5
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'do
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'code
eval: getting word value
eval: word return type: 5
eval: spec entry type: 5
eval: root loop...
eval: fetching value of type 10
eval: 'reduce
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'foo
eval: pushing function frame
eval: spec entry type: 14
eval: spec entry type: 10
eval: spec entry type: 10
eval: root loop...
eval: fetching value of type 11
eval: fetching value of type 7
eval: set-word return type: 7
eval: root loop...
eval: fetching value of type 11
eval: fetching value of type 7
eval: set-word return type: 7
eval: root loop...
eval: fetching value of type 10
eval: 'return
eval: fetching value of type 5
eval: function return type: 5
eval: spec entry type: 5
eval: spec entry type: 14
eval: spec entry type: 6
eval: spec entry type: 10
eval: spec entry type: 5
eval: spec entry type: 6
eval: fetching value of type 10
*** Error: undefined context for word 'b
;-- crashes out of the console
;-- for comparison, a functioning example of a reduce
red>> foo: func [] [return [a b]]
== func [][a: 10 b: 20 return [a b]]
red>> reduce [a b]
;-- skip console boilerplate head code
eval: action/native return type: 2
eval: root loop...
eval: fetching value of type 20
eval: path
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 12
eval: spec entry type: 5
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'do
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'code
eval: getting word value
eval: word return type: 5
eval: spec entry type: 5
eval: root loop...
eval: fetching value of type 10
eval: 'reduce
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 10
eval: 'foo
eval: pushing function frame
eval: root loop...
eval: fetching value of type 11
eval: fetching value of type 7
eval: set-word return type: 7
eval: root loop...
eval: fetching value of type 11
eval: fetching value of type 7
eval: set-word return type: 7
eval: root loop...
eval: fetching value of type 10
eval: 'return
eval: fetching value of type 5
eval: function return type: 5
eval: spec entry type: 5
eval: spec entry type: 14
eval: spec entry type: 6
eval: spec entry type: 10
eval: spec entry type: 5
eval: spec entry type: 6
eval: fetching value of type 10
eval: 'a
eval: getting word value
eval: word return type: 7
eval: fetching value of type 10
eval: 'b
eval: getting word value
eval: word return type: 7
eval: action/native return type: 5
eval: action/native return type: 10
eval: spec entry type: 5
eval: spec entry type: 6
eval: spec entry type: 14
eval: spec entry type: 6
eval: spec entry type: 11
eval: spec entry type: 5
eval: action/native return type: 5
eval: root loop...
eval: fetching value of type 10
eval: 'print
eval: pushing action/native frame
eval: spec entry type: 6
eval: spec entry type: 10
eval: evaluating argument
eval: fetching value of type 6
eval: spec entry type: 5
;-- skip console boilerplate tail code
== [10 20]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment