Having trouble getting a program running

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Having trouble getting a program running

Post by Jasoco »

I didn't even realize kikito posted his own. Ignore mine. It sucks.

Anyway, what does def do versus function? And is there any benefit to using an underscore _ in the for loop?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Having trouble getting a program running

Post by bartbes »

def vs function, well def doesn't exist.
_ vs i/k, no difference, but it tells people reading your source that you're not using it. (some languages actually see _ as an ignore keyword)
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Having trouble getting a program running

Post by Jasoco »

Oh, then why does kikito's code have def instead? Is that not valid code?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Having trouble getting a program running

Post by bartbes »

It is not.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Having trouble getting a program running

Post by Robin »

To clarify: def is in Python or Ruby what is function in Lua. I take it kikito was mistaken with one of those.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Having trouble getting a program running

Post by Jasoco »

Oh. Good. Darn, I thought it was some new way of doing things I didn't know about.

Why can't all languages be the same? lol
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Having trouble getting a program running

Post by bartbes »

Because then they'd all suck.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Having trouble getting a program running

Post by Robin »

... and you'd end up with PHP.
Help us help you: attach a .love.
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: Having trouble getting a program running

Post by Luiji »

The point of having different programming languages is so that they are different and better then each other. Personally, I wish there were less. I've learned 20 programming languages (at least), and I still haven't found the perfect one. Thus, I'm creating my own VM, etc., but that's besides the point.

So, _ tells programmers that it is ignored. That's pretty simple. It would be nice if Lua took that as a "black hole" and deleted anything sent to it (like on Linux when you redirect console output to /dev/null).
Good bye.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Having trouble getting a program running

Post by thelinx »

Luiji wrote:It would be nice if Lua took that as a "black hole" and deleted anything sent to it (like on Linux when you redirect console output to /dev/null).

Code: Select all

setmetatable(_G, {__newindex = function(table, key, value)
    if key:sub(1,1) ~= "_" then
        rawset(table, key, value)
    end
    return
end})
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 71 guests