DEV Community

I'm Luis! \^-^/
I'm Luis! \^-^/

Posted on

[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();

Enter fullscreen mode Exit fullscreen mode

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!

Top comments (4)

Collapse
 
dmfay profile image
Dian Fay

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
Collapse
 
alchermd profile image
John Alcher

I wonder if witches today practice TDD.

Collapse
 
dmfay profile image
Dian Fay • Edited

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

Collapse
 
andrewlucker profile image
Andrew Lucker

Free grammars are fun:

$$$?