Smalltalk but 20% cooler.

Introduction

Taking inspiration from:

Experiments in language design, trying to trim the fat of a bunch of cool things down to a small, but tremendously useful set of semantics:

Note: I am completely aware of the hypocrisy! This is a playground for a bunch of nifty ideas; only the niftiest will survive.

Observation:

The amount of semantics in a language (Sem(L)) is minimally bound by the amount of syntax in a language (Syn(L)):


Sem(L) = Ω (Syn(L))

I’m only half kidding about this.

Examples

Hello, World

Display print "Hello, World!"

Fizzbuzz

(1 to 100) each
    num when (num mod 15) = 0
        Display print "fizzbuzz"
    num when (num mod 3) = 0
        Display print "fizz"
    num when (num mod 5) = 0
        Display print "buzz"
    num
        Display print num toString

Type Specific Languages

# Comments are given by prefixing a line with '#'
url : URL := <https://github.com/eddieantonio/>

url path
#=> </eddieantonio> : URLPath
(url path) toString
#=> "/eddieantonio" : String

url scheme
#=> <https:> : URLScheme
(url scheme) toString
#=> "https://" : String

url domain
#=> <github.com> : Domain
(url domain) toString
#=> "github.com" : String

url match
    <_://%name%/eddieantonio>
        Display print \
            "My user name is registered on name%!"
        # Catch-all pattern. Patterns must be exhaustive.
        _
            Display print "Oh, guess I'm not registered " \
                          "on this URL afterall."
#=> My user name is registered on github.com!

url match
    <http://%name%/_>
        Display print "Golly! %name% is a secure site!"
    <http://%name%/_>
        Display print "Be carefull when dealing " \
                      "with %name%!"
#=> Golly! github.com is a secure site!

Classes and objects

Display object

print String -> void

Prints the string to the standard display.

Integer class

to (end: Integer) -> Range

Creates a new Range from the first integer to the second incrementing by 1.

mod (n: Integer) -> Integer

Modulo division. The image of the function is restricted in [0, n).

= (n: Integer) -> Boolean

Value equality. True iff the integer represents the same value as n.

Function class

documentation -> Markdown

Returns documentation assoicated with the function in Markdown format.

Object class

to (t: Type) -> Type

Attempts to coerce (oh no!) the object to type t. Actually… I don’t like this at all. Not one bit at all!

repr -> String

Prints the string representation of the object. This should just be a valid object literal that can be used to get the value again, where possible.

match -> Object

Do a pattern match on the object.

Boolean class

ifTrue (proc: -> Void) -> Computation

Executes proc only when the Boolean is the True object (inheritance-based).

ifFalse (proc: -> Void) -> Computation

Executes proc only when the Boolean is the False object (inheritance-based).

Range class

each (proc: Integer -> Void) -> Void

Executes proc on each integer sequentially.

map (fn: Integer -> A) -> Iterable[A]

Returns an iterable made by running fn on every integer. Makes no gaurentees of execution order.

Info dump!

Credits

A silly distraction for eddieantonio. This document and all of its ideas are Copyright © 2014 Eddie Antonio Santos.