Shop OBEX P1 Docs P2 Docs Learn Events
Spin1/Ruby polyglot — Parallax Forums

Spin1/Ruby polyglot

So for some reason I wondered: "Can you make a file that's both a Spin program and a Ruby program"
Then I passed out and an hour later I woke up with this in my editor (hey forum admins, why is there still no button for the code block?):
''# The amazing Ruby/Spin polyglot!
''; puts "Henlo World!"
''; text = %{
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

OBJ
pst : "parallax serial terminal"

PUB main
  pst.start(115_200)
  repeat
    pst.str(string("Henlo world!",13))

''}

'';p text

Comments

Sign In or Register to comment.