The "I Love Lua, but..." post

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The "I Love Lua, but..." post

Post by Robin »

BlackBulletIV wrote:

Code: Select all

-- take the first argument, remove all quotes, split words into an array, capitalize each word, join them back together into a string
ARGV[0].gsub(/'|"/, '').split.map {|v| v.capitalize }.join
-- generates a random 7 character strings with characters from 0-z
('0'..'z').to_a.shuffle[0..7].join
That Ruby code is channelling Pearl, banish it! Burn, ye devil! :shock:
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: The "I Love Lua, but..." post

Post by BlackBulletIV »

It would probably looking cleaner without the comments, but it's all a matter of preference. However, I don't understand what "channelling Pearl" means; only thing I can make out of it is you think it's bad, and there may be a reference to Perl (which is one of the three languages Ruby is based on - Smalltalk, Perl, Python).
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The "I Love Lua, but..." post

Post by Robin »

Yeah, I meant Perl, can't believe I misspelt that.

Anyway, Perl has the reputation of being executable line noise. Ruby's Dark Side is mostly the part that's based on the magic and cryptic notations Perl is famous for.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: The "I Love Lua, but..." post

Post by BlackBulletIV »

Believe me, I don't like Perl at all. But I'm not sure why you call that cryptic, unless of course you're not familiar with the language's core API (but this happens for every language to a certain degree). But, the strange global variables are the cryptic things in Ruby (inherited from Perl I believe) like $_, $` and so on; not that you have to use them in your code though.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The "I Love Lua, but..." post

Post by Robin »

You're right, this particular piece of code isn't that bad. But I'm not a fan of literal regexes and magic ARGV (I'm glad Lua ditched that in favour of "...").
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: The "I Love Lua, but..." post

Post by BlackBulletIV »

Well that's a point we differ on, I love regex literals. But anyway, each to their own. But I do wish ARGV could be named something more, friendly-looking; that old name was inherited from C:

Code: Select all

int main(int argc, char* argv[])
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The "I Love Lua, but..." post

Post by Robin »

Let's stop here, I've got a lot more to say, but we're derailing the thread here. ;)
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: The "I Love Lua, but..." post

Post by BlackBulletIV »

*train crash* :P Alright yeah, good idea.
Post Reply

Who is online

Users browsing this forum: slime and 2 guests