Allegro.cc - Online Community

Allegro.cc Forums » Allegro.cc Comments » Thread locks too soon

This thread is locked; no one can reply to it. rss feed Print
Thread locks too soon
Johan Halmén
Member #1,550
September 2001

A tiny crowbar. It's amazing how it fits in the smallest places and allows me to insert a heavier crowbar and finally demount things in my old house without destroying stuff very much.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

DanielH
Member #934
January 2001
avatar

Johan, years of research should have revealed that it is a red (x button) not a (red x) button. ;D

Reminds me of those stupid Jaden Smith memes.

"When you clean out a vacuum cleaner, you become the vacuum cleaner"

Johan Halmén
Member #1,550
September 2001

And when I get a divorce, my wife becomes a vacuum cleaner.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Chris Katko
Member #1,881
January 2002
avatar

{"name":"XbqnLL8.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/3\/43966bf65b1394cada8ed25edb4b43fe.jpg","w":1194,"h":879,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/3\/43966bf65b1394cada8ed25edb4b43fe"}XbqnLL8.jpg

{"name":"jK2x8KD.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d104263feb281e6e50bee3034d449bd3.png","w":469,"h":350,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/1\/d104263feb281e6e50bee3034d449bd3"}jK2x8KD.png

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Bruce Perry
Member #270
April 2000

Isn't Peter Griffin a cartoon character?

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Chris Katko
Member #1,881
January 2002
avatar

He is?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Eric Johnson
Member #14,841
January 2013
avatar

Aren't we all cartoon characters every now and again? :-[

Gideon Weems
Member #3,925
October 2003

Eric Johnson
Member #14,841
January 2013
avatar

Adult Goku or kid Goku? I favor kid Goku, as I enjoy Dragon Ball over Dragon Ball Z.

Erin Maus
Member #7,537
July 2006
avatar

In Lua, setmetatable returns the table, so you can do something like this:

t = setmetatable({}, metatable)

Which is less verbose than this:

t = {}
setmetatable(t, metatable)

Similarly, table.remove returns the removed entry, so you can do this:

return table.remove(stack, #stack)

Instead of this:

result = stack[#stack]
table.remove(stack, #stack)
return result

But table.insert doesn't return the inserted entry, which is annoying. So I can't do this:

return table.insert(stack, { foo: 1, bar: "baz" })

Instead, I have to do this:

t = { foo: 1, bar: "baz" }
table.insert(stack, t)
return t

Which seems inconsistent.

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

bamccaig
Member #7,536
July 2006
avatar

I don't think it is. In the former cases the return value was something that you didn't necessary have already. You had a metatable and an index, but not the table and value, respectively. Whereas with the insert, you already have the value that you're inserting.

Would this work:

return table.insert(stack, { foo: 1, bar: "baz" }), stack[#stack]

I think it might. In any case, while it's convenient to have clever shortcuts to things, they often can be difficult to understand at a glance which can result in more bugs. In actuality, splitting things up makes them much easier to understand. And it's not that much more to type. It's also easier to debug or extend.

For example, it's not exactly obvious what 'setmetatable' would return. Why not the metatable? Or maybe the previous metatable? You have to memorize the API to know that it returns the table itself. And if you forget that you could end up with some obscure, misbehaving code that doesn't stand out.

Erin Maus
Member #7,537
July 2006
avatar

I don't have a reference to the values because it's passed directly to table.insert without being stored in a local variable prior.

I really don't think the concise examples are any less readable than the verbose ones. It's not like I'm cramming 100 operations in a single line. I've never had problems reading Lua code formatted as such before.

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

DanielH
Member #934
January 2001
avatar

Not even spring yet and we hit 93°F today (33.9°C). They also predict his weekend will be warmer.

Eric Johnson
Member #14,841
January 2013
avatar

I hope the heat and humidity are low tomorrow. I live in Louisiana and have to drive into Mississippi tomorrow in a car without air conditioning. :(

Bruce Perry
Member #270
April 2000

Our weather here in the UK has been very windy. I'm a little windswept, short and stout.

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Gideon Weems
Member #3,925
October 2003

My brain said:

I'm a little C pot, short and stdout.

I favor kid Goku, as I enjoy Dragon Ball over Dragon Ball Z.

Interesting, as I mostly hear the opposite. Did you experience Dragon Ball first?

Eric Johnson
Member #14,841
January 2013
avatar

Interesting, as I mostly hear the opposite. Did you experience Dragon Ball first?

I don't remember exactly. I saw them both pretty close to one another, so it's all a blur. But I resonated more with Dragon Ball and its quirkiness more so than the action of Z. If I were to go back and re-watch one of them, it'd be Dragon Ball.

Bruce Perry
Member #270
April 2000

Gideon, I like your brain :)

BRAAAAAAAAAAAIIIIIIIIIIIIIN

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

bamccaig
Member #7,536
July 2006
avatar

Bruce Perry
Member #270
April 2000

bambams \ó/

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Gideon Weems
Member #3,925
October 2003

Bruce Perry
Member #270
April 2000

What's that from?

And how does your brain strike for this one: i_ò/

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

jmasterx
Member #11,410
October 2009

You guys were so busy fussing over the 1000th reply, you completely forgot about the 1024th post >:(

bamccaig
Member #7,536
July 2006
avatar

Gideon Weems
Member #3,925
October 2003



Go to: