author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 46 6a9fab6479be
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.

define [
  .proto: [.list: .nil]

  (x=[.list: _] .initialize: aList):
    (x \ [.list: aList])

  (x=[.list: l] .with: aThing):
    (x \ [.list: (l .with: aThing)])

  (x=[.list: l] .handle):
    (l .do: [eachItem: eachItem .print])

define [
  proto: [list: nil]

  (.x=[list: _] initialize: .aList):
    (.x \ [list: .aList])

  (.x=[list: .l] with: .aThing):
    (.x \ [list: (.l with: .aThing)])

  (.x=[list: .l] handle):
    (.l do: [.eachItem: .eachItem print])

The problem is really barewords. (Or applications, if you want to look at it that way.)
What if application got syntax? f $ x
$ looks like S, for Send

We need to do something about bindings, too.
var=pattern ?
var@pattern ?

define [
  proto: [list: nil]

  (x=[list: _] initialize: aList=_):
    (x \ [list: aList])

  (x=[list: l=_] with: aThing=_):
    (x \ [list: (l with: aThing)])

  (x=[list: l=_] handle):
    (l do: [eachItem=_: eachItem print])


  .list: .nil

  [.initialize: aList]:
    (self \ [.list: aList])

  [.with: aThing]:
    (self \ [.list: (self.list .with: aThing)])

    (self.list [.do: [eachItem: eachItem.print]])


  list: nil

  [initialize: .aList]:
    (.self \ [list: .aList])

  [with: .aThing]:
    (.self \ [list: (.self list with: .aThing)])

    (.self list [do: [.eachItem: .eachItem print]])

initialize: aList
     list := aList.

add: aThing
     list add: aThing.

    list do: [:eachItem | eachItem print].