TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

My newest invention: The Glas Language (A Pythonic offshot)

5 pointsby bhdzalmost 12 years ago
<p><pre><code> #!/usr/bin/env glas print: "Welcome to Glas language" Person: name: last:"Random" &#38; first: "Joe" &#38; fathers: "Someone" # name = {'last':"Random", "first": "Joe", "fathers": "Someone" } print: person's name # print(person.name) print: person's name's last # print(person.name.last) print: last' person's name arguments = alpha, beta, gamma function application: *arguments a, b, c = 1, 2, 3 calc discriminant: a, b, c # calc_discriminant(a,b,c) # Glas doesn't care much about ',' calc discriminant: a b c # Same as before call discriminant: top segment, b, c # If it sees ',' it combines # all that is listed &#38; adds it to current # first param and moves on to the # next one with "," (switches modes) object's perform something: quit:' my's company kill yourself:' motherfreaker kill:' and maim:' opponent check dead:' kill: with pistol' and maim: blunt object' opponent kill: with pistol' and maim: blunt object' opponent's check dead: # And he walked through the valey of # the shadows of death and he feared no evil # he.and_walked( # through: "valey of shadows of death") # .and_feared(not("evil") # ) and walked: "through the valey"' he's and feared: not: "evil" # Ideal for code poetry hackatons! :D # Almost sounds like a real preacher, this Glas and warneth: "of temptation"' thee's and ignoreth: me # ahahahahahaa sorry 'bout that :) my: last: "Random" &#38; first: "Joe" if len: my's last' name &#62; 10: print: "Your name is too big!" Bank Clerk: Person: initialize = my, name, job, salary, project: # my.name = name ... with my: name, job, salary, project' do: =: *project start working: project start slacking: "Doom3" start working: project' my receive payment: salary' my if my's hours &#62; 40: complain: hours' my's boss if my's salary &#60; 1500: complain: salary' my's boss start slacking' my # Oh my! </code></pre> Tell me what you think ;)<p>~ ps: Glas means Voice in Bulgarian (Глас) or even Russian!

7 comments

bhdzalmost 12 years ago
In fact, the symbols that form the syntax, doesn't matter at<p>all: standard symbol set:<p><pre><code> ~ # access, forward (standard) object ~ property -&#62; # access, backward ("homosexual" call if you will) method -&#62; object -&#62;&#62; # access, backward high ("homosexual" call with higher precedence than ~ and -&#62;... very gay...) some ~ linkage ~ method -&#62;&#62; object &#60;- # backcall semantics, normal precedence, "tailored" calling "eenie", "meeenie", "minie", "moe" &#60;- count toes: take: basket: "apples", "oranges", "bananas" &#60;&#60;- 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 </code></pre> All these operators can be a different set, but these glyphs are the best in my opinion<p>~ # PS: PLEASE do NOT get offended by my characterization<p># of certain method calls as "homosexual"<p>#<p># Don't! This is just for laughs at the language<p># I am not against gay community in any way<p># and "homosexual" calls are actually the most<p># useful feature of this language<p>#<p># Thank you.
bhdzalmost 12 years ago
<p><pre><code> a space adventure = space ship, blasters, rockets, lasers, *, **: -&#62; 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: -&#62; space ship: {{ "Weaponry detached, seek cover!" }} else: {{ "Weaponry detachment FAILED!" }} {{ \t, "AUTODESTRUCT SEQ. INITIATED" }} {{ \t, "EJECT EJECT EJECT!" }} auto destruct: 20s -&#62; space ship</code></pre>
评论 #5817798 未加载
bhdzalmost 12 years ago
New ROCKING syntax!<p><pre><code> #!/usr/bin/env glas # # Yay, and hear these spoken words of wisdom, Stranger: # and: he ~ walked: through the valley ~ valley + shadows &#38; valley + shadows + death --&#62; 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)) )</code></pre>
评论 #5817646 未加载
bhdzalmost 12 years ago
Glas doesn't care about keywords actually, the only "keywords" are the syntactic elements like ~ -&#62; -&#62;&#62; { [ {{ {&#62; &#60;}<p>so you write:<p><pre><code> if: something ~ happened: and: something else ~ happened: logic ~ did: something ~ happened # ? </code></pre> and<p><pre><code> for: x in: range: 12, 32 {{ x }} </code></pre> this chains the needed things nicely in fact you can write like this:<p><pre><code> in: range: 5, 13 perform: a task for: x in: iter: person {{ x }}</code></pre>
bhdzalmost 12 years ago
If you find '.' and ''' and ''s' offending, you can change the symbol to the old dot and "@" for instance.<p>and that's much better than that.much better, don't you think?<p><pre><code> 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!"</code></pre>
bhdzalmost 12 years ago
For more:<p><pre><code> git clone https://github.com/bhdz/glaslang.git</code></pre>
lifeisstillgoodalmost 12 years ago
Afaik my's last' name is equivalent to<p>my.name['last']<p>How does the ' operator decide between need for 's and not?<p>Where is the GitHub page? :-) What did you learn :-) Who are you ?<p>Nice one
评论 #5812012 未加载
评论 #5811855 未加载
评论 #5817665 未加载
评论 #5811872 未加载