Smalltalk but 20% cooler.
Taking inspiration from:
docstrings
and doctest
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.
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.
Display print "Hello, World!"
(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
# 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!
Display
objectprint String -> void
Prints the string to the standard display.
Integer
classto (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
classdocumentation -> Markdown
Returns documentation assoicated with the function in Markdown format.
Object
classto (t: Type) -> Type
Attempts to coerce (oh no!) the object to type Actually… I don’t like this at all. Not one bit at all!t
.
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
classifTrue (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
classeach (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.
A silly distraction for eddieantonio. This document and all of its ideas are Copyright © 2014 Eddie Antonio Santos.