moo/moo
2019-07-14 16:46:08 +00:00
..
ac regenerated build files 2018-06-19 02:12:03 +00:00
bin reorganized moo_duputobcstr(), moo_dupbtoucstr(), moo_dupbtouchars(), moo_duputobchars(). 2019-07-10 09:19:38 +00:00
kernel removed code_start_loc from moo_method_data_t and added start_loc 2019-07-12 08:05:44 +00:00
lib defined MOO_EXPORT to EMSCRIPTEN_KEEPALIVE for EMSCRIPTEN 2019-07-14 16:34:16 +00:00
m4 regenerated build files 2018-06-19 02:12:03 +00:00
mod fixed some inconsistency in moo_fmt_object_(). 2019-05-30 15:44:24 +00:00
t finished refactoring fmt code in fmt.c. 2019-05-29 09:20:45 +00:00
aclocal.m4 regenerated build files 2018-06-19 02:12:03 +00:00
configure gui log view experiment with gtk 2019-05-22 08:49:27 +00:00
configure.ac gui log view experiment with gtk 2019-05-22 08:49:27 +00:00
emcc.txt defined MOO_EXPORT to EMSCRIPTEN_KEEPALIVE for EMSCRIPTEN 2019-07-14 16:34:16 +00:00
Makefile.am added the bin directory and moves files for binary commands into it 2019-05-14 04:07:23 +00:00
Makefile.in gui log view experiment with gtk 2019-05-22 08:49:27 +00:00
README.md updated README.md with some TODOs 2019-07-14 16:46:08 +00:00

Top-level elements

  • #include
  • #pragma
  • class
  • interface
  • pooldic

Comments

#! comment text
// comment text
/* comment text */

Literal notations

  • 200 decimal integer

  • 2r1100 binary integer

  • 16rFF00 hexadecimal integer

  • 20p9999.99 fixed-point decimal where 20 is the number of digits after the point

  • 999.9 fixed-point decimal

  • $X character

  • C'X' -> charcter??

  • C"X" -> character??

  • 'XXXX' string literal

  • "XXXX" string litearl with escaping

  • B'XXXXXX' -> byte array literal

  • B"XXXXX" -> byte array literal with escaping

  • #XXXX symbol

  • #'XXXX' quoted symbol

  • #"XXXX" quoted symbol with escaping

  • #\e123 Error literal

  • #\pB8000000 SmallPointer(smptr) literal

  • #() Array. Comma as element delimiter is optional

  • #[] ByteArray. Comma as element delimiter is optional

  • #{} Dictionary - not supported yet

The following are not literals. The followings forms expressions.

  • ##() Array expression. Comma required to delimit elements

  • ##[] ByteArray expression. Comma required to delimit elements

  • ##{} Dictionary expression. Comma required to delimit elements

  • S%[] String literal with each character specified ** S%{A B C '\n'}

  • S%{} String with dynamic expression

  • S%{ 65 asCharacter, 64 asCharacter }

Class

class MyClass(Object)
{
	method show: this
	{
	}
}

Flow Control

k := if (i < 20) { 30 } else { 40 }.

if (a < 10) { ... }
elsif (a < 20) { ... }
else { ... }.
while (true)
{

}.

until (a > b)
{
}.

do
{
} while (a > b).

do
{
} until (a > b).

[a > b] whileTrue: [ ... ].
[a > b] whileFalse: [ ... ].
1 to: 20 do: [:count | ... ].
1 to: 10 by: 3 do: [:count | ... ].
30 timesRepeat: [ ... ].

Exception handling

Exception signal. Exception signal: "message".

[ ... ] on: Exception do: [:ex | ... ].

ex retry. ex resume. ex resume: value. ex return: value.

goto

goto jump_label.

jump_label::
	a + b;

useful to make a block return can i deprecate the ^^ operator?

[ 1 + 2. goto r. 3 + 4. r::]

goto must not cross the boundary of the block context.

this is invalid. cannot jump into a block from outside 
and vice versa.
 goto x.
 [ x:: 
   1 + 2 ].

Type checking

Type checking not implemented yet.

class SampleClass(Object)
{
	method run => Integer
	{
	}

	method execute((Integer)a,(Integer)b) => Integer
	{
	}

	method handle: (Object)this with: (a Integer)care => Integer
	{
	}
}

TODO: How to specify return type of a block? or How to specify parameter type to a block? How to evaluate a block type-safely?

[ :(Integer)a :(Integer)b => Integer | 
	| (Integer)c (Integer)d }
	a + b 
] with: 20 with: 10

the method value is a variadic method. and it is a primitive.
[ :a :b | a + b ](1, 20) <---- syntax sugar for [:a :b | a + b] value(1, 20).

[:(Integer)a :(Integer)b => Integer | a + b ] value("kkkk", 20) 
 -> the first argument violates the expected type.
 -> argument types to a method is defined in the method signature.
 -> but the block argument types are specified in the block itself.
 -> so it doesn't seem natural to achieve type safety without treating 'value' specially.
 -> create a shorthand expression for 'value' [:(Integer)a :(Integer)b => (Integer) | a + b ](1, 2)
 -> ] followed by ( ===> shorthand expression for value.
 -> it looks more sensible to treat this () specially
 
what looks better as a shorthand expression for block value?
 [ :a :b | a + b ](10, 20)
 [ 10 + 20 ]() // no arguments
 [ :a :b | a + b ]->(10, 20). // -> cannot form a valid binary selector. must exclude it from binary selector patterns
 [ 10 + 20 ]->() // if no arugments are required.
 
 continuation?
 | a |
 a->()? block value?
 
 | (Block)a |
 a->()? block value?