To be fair, it sounds like he was just trying to help. I read through everything, and while GatewayRa's example was more optimized I can't help but frown due to the fact that a guy with less experience was just trying to help out and it turned into all of this.

If every time I posted a code snippet a better developer came along and did this I'd be really upset too. It's not like Alex Peterson's code NEEDED optimizing.

@Alex Peterson, I can see myself using a queue system like that only if more functionality was added. Such as a server login queue and such, otherwise using lists work just as well and is kind of redundant. I do appreciate the effort though.
There will always be someone better than you at everything. There will almost always be better ways to do something.

For example, GatewayRa's code, although compact, fails for non-true list entries per if(.). But that is easily fixed and ends up looking more like Alex Peterson's code.
In response to Kaiochao
Kaiochao wrote:
There will always be someone better than you at everything. There will almost always be better ways to do something.

For example, GatewayRa's code, although compact, fails for non-true list entries per if(.). But that is easily fixed and ends up looking more like Alex Peterson's code.

This. Not to say anyone here is the better programmer. I just can't fathom when people lecture on a snippet like this and then have virtually the same code with virtually the same performance. It comes off to me as extremely obnoxious.
His argument is not trash, and every bit of efficiency matters under an unoptimized and interpreted virtual machine, as it becomes an exponentially noticeable difference when the asynchronous operations tally up to the total performance cost. He may not have accounted for null values, but that's easily rectified as so while still retaining the elevation of performance:
abstractListI

var contents[0]

proc

Clear() src.contents.len = 0
IsEmpty() return !src.contents.len
Peek() if(src.contents.len) return src.contents[src.contents.len]

queue

parent_type = /abstractListI

Peek() if(src.contents.len) return src.contents[1]

proc

Dequeue() if(src.contents.len)

. = src.contents[1]
src.contents.Cut(1, 2)

Enqueue(foo) src.contents += foo

stack

parent_type = /abstractListI

proc

Pop() if(src.contents.len)

. = src.contents[src.contents.len]
-- src.contents.len

Push(foo) src.contents += foo


My question is, why are you making tutorials when Lavitz clearly pointed out that you're a beginner programmer? And what's more is that you aren't open to suggestions of improvement. Maybe you should study up on the fundamentals of programming a bit more before you decide to post tutorials, yes?
Page: 1 2