[ANN] Towards a new File In / File Out format

astares at gmx.de astares at gmx.de
Mon May 29 17:24:34 UTC 2006


Hi Noury,

I would not use the "<<" message for two reasons:
 - in other languages this is an operator for streaming (C++)
 - if you describle a method you write class>>#method instead of class<<#method

I personally like the format that is used in Smallscript/S# called
AML (AOS Meta Language). 

A small example for a class:
============================

    Class name:	Person
       extends: Object
        fields: firstName sureName [       
       ...       
    ]

You can use []-notation as well as {}-notation and since the default superclass is Object you can also write:

	Class name: Person 
	    fields: firstName sureName {
	    ...
	}

You can also pass it directly to the compiler as XML 

    <class name="Person" extends="Object" fields="firstName sureName">
		<method ...
    </class>

Since you can map it to XML you can also provide an XSD where the defaults for attributes (like the default "Object" for the "extends" attribute can be defined).

In XML/AML there is no order for attributes - so you can also write:

	Class fields: firstName surname name: Person [
	   ...
	]
 
A small example for a method:
============================

This also allows for easier extension - just add attributes or subnodes.
Either nest it into a class definition 

     Class name: Person [
     	Method [
     		foo
     			^self
     	]
     }

or create the Method on an existing class (extension)

	Method class: String category: conversion {
		asFoo
			^Foo from: self
	}
	
You can also have class-less or global Methods (Functions) 

   Function [
   		foo
   			^self
   ]
   
  

A small example for evaluation: 
===============================

use "Eval", here is a simple HelloWorld example:

	Eval [stdout << 'HelloWorld' ]

where stdout is a global variable like Transcript and << is a binary message.

You can also advice the compiler in a script:

	Compiler cmds: '-rdb:off -target:console'.

or load other modules:

	Load module: ANSISmalltalk.
	Load module: AOSUnit.
	Load module: PointExt.

or combine the format with annotations:

	Function [<$entrypoint>
	  main
	  	Transcript show: 'HelloWorld';
	]
	
	Method class: Point [
		+ <Point> anotherPoint
		    "Adds the arguments coordinates to the receiver."
		     ^(self x + anotherPoint x) @ (self y + anotherPoint y)
	].


The main AML elements are: Class, Module, Library, Method, Function, Compiler, Eval, Enum, Namespace, ...

There is some more syntactic sugar in the ST parser to help people coming from a different language background. So you can also write

	Transcript.show('HelloWorld');
or
        Transcript.show: 'HelloWorld';

This may be ugly for a Smalltalker and confuse people since you can mix styles. Think of 
  
But XML based AML as file in/file out format is worth a look!!!

Some pointers to examples: 
  http://www.edwin-buehler.net/smallscript.shtml
  http://www.double.co.nz/smallscript/index.htm
  http://www.metaprog.com/SmallScript/download.htm  

Bye
Torsten

BTW: Smallscript/S# are separate systems: Smallscript is free, running
     on the free AOS (Agent Object System)VM which is downloadable
     from smallscript.org. David made all of that completely free to use!
     The S# part running on .NET is not public. Unfortunately the ST      
     community was/is not so interested in the Smallscript part - but
     especially this one really rocks. Write a small script - pass it 
     to the command line compiler and build fast DLL's, small executables,
     modules or full applications ... 


-- 


Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
      Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
    



More information about the Squeak-dev mailing list