• Print

Author Topic: Today I learned...  (Read 4696 times)

0 Members and 1 Guest are viewing this topic.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Today I learned...
« on: January 04, 2015, 11:28:47 am »
Today I learned that _G, the global table that stores all global data in Lua, can reference itself...
That means, a script like this:
Code: Lua
  1. print( _G['_G'] == _G )
... prints "true".

That also means that a script like this...
Code: Lua
  1. print(
  2.                 _G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G._G == _G
  3.         )
... also prints "true".

Funny how programming can work, eh?
bw81@ulysses-forums ~ % whoami
Homepage

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Today I learned...
« Reply #1 on: January 10, 2015, 11:25:04 am »
It's like googling the word "recursion". :)
Experiencing God's grace one day at a time.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Today I learned...
« Reply #2 on: January 10, 2015, 05:21:29 pm »
It's like googling the word "recursion". :)
I know what recursion is. :P
I just find such things as this slightly humorous—for some reason, I tend to exhale sharply out my nose when I see something like this at work.
bw81@ulysses-forums ~ % whoami
Homepage

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Today I learned...
« Reply #3 on: January 10, 2015, 08:40:52 pm »
He wasn't implying that you didn't know what recursion meant.

Literally.. google it. It's an easter egg.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Today I learned...
« Reply #4 on: January 10, 2015, 11:28:37 pm »
He wasn't implying that you didn't know what recursion meant.

Literally.. google it. It's an easter egg.
Okay, let's see here...
*** enters "recursion" into Chrome Omnibar
Did you mean: recursion
... uh...
... Wait a sec—OOOOOOHHHHHHHHHHHHHHHHHHHHHHHHHH!

Merp.
bw81@ulysses-forums ~ % whoami
Homepage

  • Print