# HG changeset patch # User IBBoard # Date 1505764416 -3600 # Node ID 6347bacb3be7fc3bcef170b3afb5c977655a037e # Parent d2764720ea17158cfcfbeb3536926d62effff2b7 Add more notes about the DSL while I think about it Note: Several things don't make sense diff -r d2764720ea17 -r 6347bacb3be7 2-Io/day3-DSL.io --- a/2-Io/day3-DSL.io Mon Sep 18 20:45:32 2017 +0100 +++ b/2-Io/day3-DSL.io Mon Sep 18 20:53:36 2017 +0100 @@ -10,15 +10,30 @@ # This is hidden black magic that you need to know about to override it. # It appears to call the method for all of the content within the brackets. curlyBrackets := method( + # Create a map map := Map clone + # Foreach arg that got passed (each comma-separated line within the brackets) + # then run that on the map + # Note: It isn't clear why ":" operates on the map at this point + # The book says "we'll execute `map atPutThing(a, b)`" but why? + # Colon was originally on a string, not the map, so how does it know to invoke on the map? call message arguments foreach(arg, + # Based on the following println then it is already "atPutThing(a, b)" by this point + # but the ordering still doesn't make sense. + # See also http://iolanguage.org/guide/guide.html#Syntax-Operators + #arg println map doMessage(arg) ) + # Return the map (last line's return is the return) map ) Map atPutThing := method( + # Call the standard method self atPut( + # And pull the call args to pass through + # NOTE: arg 1 has its quotes stripped automatically because it's a number + # or some other magic! call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""), call evalArgAt(1) )