My newest invention: The Glas Language (A Pythonic offshot)
7 comments
In fact, the symbols that form the syntax, doesn't matter at
all: standard symbol set:
~ # PS: PLEASE do NOT get offended by my characterization
# of certain method calls as "homosexual"
#
# Don't! This is just for laughs at the language
# I am not against gay community in any way
# and "homosexual" calls are actually the most
# useful feature of this language
#
# Thank you.
all: standard symbol set:
~ # access, forward (standard)
object ~ property
-> # access, backward ("homosexual" call if you will)
method -> object
->> # access, backward high ("homosexual" call with higher precedence than ~ and ->... very gay...)
some ~ linkage ~ method ->> object
<- # backcall semantics, normal precedence, "tailored" calling
"eenie", "meeenie", "minie", "moe" <- count toes:
take: basket: "apples", "oranges", "bananas" <<- fill basket:
# take(basket().fill_basket("apples",...), ...)
# BE CAREFUL with that code above
# basket doesn't get created with the fruits, just empty basket which
# is subsequently filled with goodies
All these operators can be a different set, but these glyphs are the best in my opinion~ # PS: PLEASE do NOT get offended by my characterization
# of certain method calls as "homosexual"
#
# Don't! This is just for laughs at the language
# I am not against gay community in any way
# and "homosexual" calls are actually the most
# useful feature of this language
#
# Thank you.
a space adventure = space ship, blasters, rockets, lasers, *, **: -> Space Ship:
space ship ~ attach weapons: blasters, rockets, lasers:
{{ "Eeeekkrrrrgh! Weapons attached successfully!" }}
{{ "listing:" }}
for weapon in *: #all arguments of attach weapons
{{ "Weapon:", weapon }}
else:
{{ "WARNING! WARNING! Ship weaponry attachment FAILED }}
{{ "You're defenseless!" }}
detach weapons: -> space ship:
{{ "Weaponry detached, seek cover!" }}
else:
{{ "Weaponry detachment FAILED!" }}
{{ \t, "AUTODESTRUCT SEQ. INITIATED" }}
{{ \t, "EJECT EJECT EJECT!" }}
auto destruct: 20s -> space shipAh yes!
{{ \t, "eject eject eject!" }}
auto destruct: 20s -> space ship
{> user ejected % wait: 20s, any -> input <}
{{ "Your ship explodes in a gigantic fireball!" }}
if: empty: -> input ->> user ejected
{{ "You fail to eject, Ouch!" }}
space ship ~ pilot ~ die: "massive splosion"
space ship ~ destruct: "massive splosion"New ROCKING syntax!
#!/usr/bin/env glas
#
# Yay, and hear these spoken words of wisdom, Stranger:
#
and: he ~ walked: through the valley ~
valley + shadows &
valley + shadows + death -->
and: he ~ feared: not: evil
#
# versus the barbaric cries of the past!
#
#! old pythonic
#
and(
he.walked( through_the_valley.combine(
[valley, shadows], [valley, shadows, death] )
).and( he.feared(not(evil)) )Now you can use the familiar
do something: a dict ['some key'], coordinates['x']Glas doesn't care about keywords actually, the only "keywords" are the syntactic elements like ~ -> ->> { [ {{ {> <}
so you write:
so you write:
if: something ~ happened: and: something else ~ happened:
logic ~ did: something ~ happened # ?
and for: x in: range: 12, 32
{{ x }}
this chains the needed things nicely
in fact you can write like this: in: range: 5, 13
perform: a task
for: x in: iter: person
{{ x }}If you find '.' and ''' and ''s' offending, you can change the symbol to the old dot and "@" for instance.
and that's much better than that.much better, don't you think?
and that's much better than that.much better, don't you think?
cookie adventure: my @ Cookie Monster =
print "Cookie Monster, why is the Cookie jar empty?"
why: my.cookie.jar.empty: @ cookie monster
# why cookie monster, why? :)
why: my.cookie.jar.empty: @ cookie monster .why: "tell me!"For more:
git clone https://github.com/bhdz/glaslang.gitAfaik my's last' name is equivalent to
my.name['last']
How does the ' operator decide between need for 's and not?
Where is the GitHub page? :-) What did you learn :-) Who are you ?
Nice one
my.name['last']
How does the ' operator decide between need for 's and not?
Where is the GitHub page? :-) What did you learn :-) Who are you ?
Nice one
Nevermind that, listen to this:
nevermind: that --> listen: this ~ to
# nevermind(that).listen(this.to)
# All you do is complain and whine to your boss,
# slacking, sipping a lot of coffee at the coffeeshop:
complain: and whine -> my ~ boss -> slack: sip coffee: a lot --> coffeeshop
# my.boss.complain(and_whine).slack(
# coffeeshop.sip_coffee(a_lot)
# )
foo: normal dict['some key'] -> bar
;):D
It doesn't care basically if it's encountering a dict ({}), an object, or a function/method.
If it's not a function then it's either a dict OR another object instance. it it's a function it applies it! Glas treats everything as potential functions or procedures (no arguments) math sin: x could be _anything_ really :)
Use '$' sign if you wish to refer to function's object explicitly like this:
It doesn't care basically if it's encountering a dict ({}), an object, or a function/method.
If it's not a function then it's either a dict OR another object instance. it it's a function it applies it! Glas treats everything as potential functions or procedures (no arguments) math sin: x could be _anything_ really :)
Use '$' sign if you wish to refer to function's object explicitly like this:
a function name # could be application?
$ a function name # definitely function object to be referred!Ah! Yes! :)
I had some kind of a satori Saturday, so it's still just a glas.py file which aims are being a simple as possible translator into Python. (for now it just parses it and evals it like a barbarian, and still not workable ;))
I will make a repo later today, after work.
I had some kind of a satori Saturday, so it's still just a glas.py file which aims are being a simple as possible translator into Python. (for now it just parses it and evals it like a barbarian, and still not workable ;))
I will make a repo later today, after work.
Just like Python, Glas (Глас) doesn't really distinguish between dicts, objects or methods/functions. For it functions are just a fancier version of objects which are a fancier version of normal dicts. Later on, during evaluation, Glas makes a distinction, not before though.
I am planning on adding additional features like adding statements after each method call with the ':' operator, like this:
I am planning on adding additional features like adding statements after each method call with the ':' operator, like this:
# ship.attach_weapons(...):
ship's attach weapons: blasters, rockets, lasers:
print "Eeeekkrrrrgh! Weapons attached successfully!"
print "listing:"
for weapon in *: #all arguments of attach weapons
print "Weapon:", weapon
else:
print "WARNING! WARNING! Ship weaponry attachment FAILED"
print "You're defenseless!"
detach weapons:' ship:
print "Weaponry detached, seek cover!"
else:
print "Weaponry detachment FAILED!"
print " AUTODESTRUCT SEQ. INITIATED"
print " EJECT EJECT EJECT!"
auto destruct: 20s' ship
Tell me what you think ;)
~ ps: Glas means Voice in Bulgarian (Глас) or even Russian!