[Challenge] Can you play with your language's syntax without breaking it?

Four years ago I was so bored I made this:

<?php
$lol = "lol";
define("HAHA", $lol, 1);
class ha
{
    public function result()
    {
        return 'This will be the result!';
    }
}
class idk
{
    public function lol()
    {
        return array(0, new ha() );
    }
}
function lol()
{
    return array( new idk() );
}
echo ${HaHa}()[0]->{${$lol}}()[1]->result();

This still works on PHP 7.1! Can you do it with your favorite language?

NOTE: This is just for fun. Don't do this while actually coding!

Did you find this post useful? Show some love!
DISCUSSION (5)

I've barely touched perl, but the program/poem "Black Perl" is infamous:

BEFOREHAND: close door, each window & exit; wait until time.
    open spellbook, study, read (scan, select, tell us);
write it, print the hex while each watches,
    reverse its length, write again;
    kill spiders, pop them, chop, split, kill them.
        unlink arms, shift, wait & listen (listening, wait),
sort the flock (then, warn the "goats" & kill the "sheep");
    kill them, dump qualms, shift moralities,
    values aside, each one;
        die sheep! die to reverse the system
        you accept (reject, respect);
next step,
    kill the next sacrifice, each sacrifice,
    wait, redo ritual until "all the spirits are pleased";
    do it ("as they say").
do it(*everyone***must***participate***in***forbidden**s*e*x*).
return last victim; package body;
    exit crypt (time, times & "half a time") & close it,
    select (quickly) & warn your next victim;
AFTERWORDS: tell nobody.
    wait, wait until time;
    wait until next year, next decade;
        sleep, sleep, die yourself,
        die at last

I wonder if witches today practice TDD.

TDD sounds more alchemical or goetic but I suppose everybody's a syncretist nowadays.

This talk at RubyConf 2017 has some of the most impressive, mind-boggling, examples of this that I've ever seen: confreaks.tv/videos/rubyconf2017-e...

Classic DEV Post from Aug 8

Got My First Pull Request Accepted and Merged

Holy Shit, I Made Something That Someone Else Was Like "Ya, that works." Check...

I'm Luis! \^-^/
A web developer interested in learning a bunch of new stuff. I HAVE A LOT OF FREE TIME so feel free to reach me if you want help in your project or company!

dev.to is where software developers stay in the loop and avoid career stagnation.

Sign up (for free)