changeset 44:6347bacb3be7

Add more notes about the DSL while I think about it Note: Several things don't make sense
author IBBoard <dev@ibboard.co.uk>
date Mon, 18 Sep 2017 20:53:36 +0100
parents d2764720ea17
children 8a2451a7b86e
files 2-Io/day3-DSL.io
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)
     )