Random programming language ideas. (The name drops the letter 'a', as in a certain other language's name)
"string"
'string' # alternate string syntax
/regex/
%regex% # alternate regex syntax
<>xml<>
{lambda}
(list) # automatically detected as an array/hash/object
@(array)
%(hash)
&(object)
$variable
# comment
#* block comment *#
$!lambda
$%hash
$@array
$&object
$#integer
$.float
$"string
$/regex
$<xml
${Object}anything
Other reserved type prefixes: '~[^$
\$(<type>{\w+}|[^\w\s])?(<name>\w+)
# arrays may only consist of integer keys
@(0; 'hi'; 'two'; 3; 4)
# hashes allow named elements
%(one: 1; item: 'foo')
# objects allow special overrides
&(
property: value
extra: {
print 'hello'
}
get extra: {
return 'hi'
}
get __property__: {
}
get __method__: {
}
)
The null object contains parameters passed to a lambda
$~named # named argument
$['named'] # also valid
$[0] # unnamed argument
$$ # object itself
Examples:
define hello {
print 'Hello ' . $~place
}
# prints 'Hello world'
hello(place: 'world')
define hello2 {
print 'Hello ' . $[0]
}
# prints 'Hello world'
hello2('world')
Valid:
if $var == 'foo' {
}
Invalid:
if $var == 'foo'
{
}
Translates to:
if $var == 'foo';
{
}
Returns 'asdf':
{
'asdf'
}
$/{ '/hello/:name'~replace(/:(\w+)/, '(<name>\w+)')) }
$route~get('/hello/:name'; {
# Need the raw variable? Use the XML $<, everything else is escaped.
<>
<!doctype html>
<h1>Hello $~name!</h1>
<>
})
unless $var {
print 'asdf';
}
<>
<ul>
$foo~each({
<><li>$~item</li><>
})
</ul>
<>
define name
define operator name
define unary operator name
define binary operator name
define ternary operator name1 name2
if 2 in (1;2;3) {
# foo
} else {
# bar
}
each 1..5 {
}
for {$i=0; $i<1; $i++} {
}
while true {
}
each $array {
print "$~key: $~value"
}