r3/SyntaxNotes
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 52 e8c6861a3e40
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     1
-*- outline -*-
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     2
52
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     3
* Basics, Revised Yet Again
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     4
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     5
The question is how to deal with currying, and reconciling the
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     6
difference between send syntax and pattern-match syntax. A chain of sends might
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     7
look like any of:
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     8
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
     9
	r1 Class FieldNames
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    10
	r1 IfTrue: v1 IfFalse: v2
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    11
	dict Lookup: key [IfPresent: .v]: v IfAbsent: 123
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    12
	v1 == v2
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    13
	v1, v2, v3
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    14
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    15
A method clause:
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    16
  .m@[.self Lookup: .aKey]: ((self HasKey: aKey) IfTrue: (m IfPresent: (self At: aKey)) IfFalse: (m IfAbsent))
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    17
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    18
The other problem is centralised dispatch (by the interpreter and
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    19
current context) vs. distinguished-receiver ST80-style dispatch.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    20
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    21
I guess it comes down to the shape of messages constructed by dispatch
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    22
syntax. With a central dispatcher, we get
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    23
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    24
	[0: [0: r1 1: Class] 1: FieldNames]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    25
	[0: r1 IfTrue: v1 IfFalse: v2]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    26
	[0: dict Lookup: key [IfPresent: .v]: v IfAbsent: 123]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    27
	[0: [0: (==) 1: v1] 1: v2]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    28
	[0: v1 1: v2 2: v3 Length: 3]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    29
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    30
Corresponding patterns could be
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    31
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    32
	[.self Class]: ...
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    33
	[.self FieldNames]: ...
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    34
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    35
Hmm, essentially, when a pattern fails to match, it calls resend! So
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    36
if we had a high-priority pattern [.self Class FieldNames] matching
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    37
against [foo Class SomethingElse] we''d see the [foo Class] match the
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    38
[.self Class], resulting in [[_ FieldNames]: ... _: resend] or
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    39
similar. This, when sent [(itself) SomethingElse], would backtrack to
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    40
matching against some other receiver for [.self Class], if any.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    41
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    42
	[.self IfTrue: .vt IfFalse: .vf]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    43
	[.self Lookup: .aKey]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    44
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    45
	"This next one is tricky:"
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    46
	m@[.self Lookup: .aKey [IfPresent: _]: _ IfAbsent: _]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    47
	"Note in the above that the first _ is a value, ie. top!"
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    48
	"(rather than a pattern ie. bottom)"
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    49
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    50
	[.val == .other]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    51
	[.v1, .v2, .v3]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    52
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    53
Perhaps remove (,,) syntax? Maybe it could be sugar for list/stream
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    54
construction? For instance:
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    55
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    56
	(v1, v2, v3) ==> (v1 . (v2 . (v3 . Nil)))
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    57
	[.v1, .v2, .v3] ==> [.v1 . [.v2 . [.v3 . Nil]]]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    58
			==> [(.) .v1 ((.) .v2 ((.) .v3 Nil))]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    59
			decurrying ==>
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    60
		[0: (.) 1: ...? "difficulty."
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    61
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    62
Maybe keyword syntax instead:
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    63
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    64
	(v1, v2, v3) ==> (First: v1 Rest: (First: v2 Rest: (First: v3 Rest: Nil)))
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    65
	[v1, v2, v3] ==> [First: v1 Rest: [First: v2 Rest: [First: v3 Rest: Nil]]]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    66
	[.v1, .v2, .v3] ==> [First: .v1 Rest: [First: .v2 Rest: [First: .v3 Rest: Nil]]]
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    67
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    68
That''s better. It makes sense, too, since once (,,) is no longer
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    69
tupling, the only n-ary syntax we have is the pattern/value
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    70
syntax. Binary operators turn into curried application, which is
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    71
tricky to pattern-match.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    72
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    73
Shit, there's another tricky case: the difference between [x] and x;
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    74
or, more properly, between (x) and x.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    75
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    76
	(x) ==> (First: x Rest: Nil)
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    77
	x   ==> x
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    78
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    79
Wrong! So, we need some kind of marker in the syntax. Unless... what
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    80
if we reinterpret (,) as a stream-cons operator rather than a
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    81
stream-separation operator?
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    82
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    83
(This, incidentally, is where python's (x,) syntax comes in.)
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    84
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    85
	(1, 2, 3) --> (First: 1 Rest: (First: 2 Rest: 3))
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    86
	(1, 2, 3, [])
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    87
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    88
Yuck. What about a right-associative flipped application operator (snoc)?
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    89
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    90
	1, 2, 3 <==> ((,) ((,) 3 2) 1)
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    91
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    92
Read them as begin?
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    93
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    94
	(begin x y z) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    95
	(begin (begin x y) z) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    96
	(begin x (begin y z)) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    97
	(begin (begin x) (begin y) (begin z)) == etc.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    98
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
    99
	(x, y, z) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   100
	((x, y), z) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   101
	(x, (y, z)) ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   102
	((x), (y), (z)) == etc.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   103
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   104
That's better. So, (,) becomes an n-ary tupling syntax again, in a
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   105
way.
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   106
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   107
	[x, y, z] ==
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   108
	[[x, y], z] == ... Hmm. Not so pretty here?
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   109
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   110
Actually, there's also a problem with scoping rules, if begin is used
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   111
like a let* or a letrec: What does ((.a <- b, c), a) mean?
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   112
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   113
* Basics
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   114
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   115
	pattern: value pattern: value ...	(fun (pattern value) ...)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   116
	value, value, value, ...		(tuple value ...)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   117
	value value				(adj value value)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   118
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   119
	( value )				; grouping
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   120
	[ value ]				(quunquote value)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   121
	#[ value ]				(quasiquote value)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   122
	#( value )				(unquote value)
45
604988e365e5 Dot for quote, instead of hash
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 44
diff changeset
   123
	. value					(quote value)
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   124
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   125
	atom					; symbols
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   126
	'another atom'				; symbols
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   127
	literal					; literal object sugar (strings, ints)
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   128
						; unit, nothing at all
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   129
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   130
	"a comment"				; comments
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   131
44
7daa729ed442 Reminder to think about bit-syntax.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 40
diff changeset
   132
TODO: Bit syntax!
7daa729ed442 Reminder to think about bit-syntax.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 40
diff changeset
   133
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   134
* Tuples, Records and Functions
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   135
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   136
[] is both the empty quoted tuple and the empty quoted function.
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   137
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   138
Tuples are sugar for functions with integer patterns! Like this:
52
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   139
(x, y, z)   <==>   (.length: 3 0: x 1: y 2: z)
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   140
52
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   141
(... or something. The ".length: 3" could instead be ".tuple: .tuple",
e8c6861a3e40 More experimental noise, this time from work's checkout
Tony Garnock-Jones <tonyg@lshift.net>
parents: 45
diff changeset
   142
as an "interface marker" of some kind)
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   143
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   144
The empty tuple/function is "unit".
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   145
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   146
* Interpretation
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   147
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   148
Non-quoted tuples are sugar for monadic sequencing, that is /bind/
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   149
operations.
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   150
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   151
Non-quoted functions are messages sent to the ambient.
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   152
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   153
Non-quoted adjacency is function application == message send.
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   154
40
e38cbf5bb340 More notes.
Tony Garnock-Jones <tonyg@lshift.net>
parents: 38
diff changeset
   155
Non-quoted symbols are variable references.
e38cbf5bb340 More notes.
Tony Garnock-Jones <tonyg@lshift.net>
parents: 38
diff changeset
   156
e38cbf5bb340 More notes.
Tony Garnock-Jones <tonyg@lshift.net>
parents: 38
diff changeset
   157
Non-quoted literals are self-evaluating.
e38cbf5bb340 More notes.
Tony Garnock-Jones <tonyg@lshift.net>
parents: 38
diff changeset
   158
38
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   159
* Quoting
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   160
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   161
** Quote
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   162
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   163
** Quasiquote and unquote
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   164
a9298e1465b6 Notes on planned syntax + meaning
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
   165
** Quunquote