Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Lua is terrible. Don't use it.

Name: Anonymous 2011-09-30 22:32

For those of you demanding a reason Lua is shit,
consider the following code:


local fh = io.open(filename, "r")  
while true do
    line = fh:read("*l")
    if line == nil then break end
    f(line)
end


That is a fucking eyesore. The whole point of a while loop is to embed the exit condition in it. When you have to make an infinite loop and then use an if statement with a break to accomplish what you can normally do with something like:


fh = fopen(filename, "r");  
while(fgets(line, max, fh) != NULL) {
    f(line);
}


that's when you need to stop using that language. Also why do if statements have "then"s? Any programming language that uses "then" is awful.

Name: Anonymous 2011-10-05 2:29

>>51

I bet you could do it using python's immutable tupples, giving an immutable tree with variable degree vertices. The path copying would have to be implemented yourself, and it probably wouldn't fly too well with high degree vertices.


>>> tree = (((1, 2), (3, 4)) ((5, 6), (7, 8)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable
>>> tree = (((1, 2), (3, 4)), ((5, 6), (7, 8)))
>>> print tree
(((1, 2), (3, 4)), ((5, 6), (7, 8)))
>>> tree2 = ((10, 11), tree)
>>> print tree2
((10, 11), (((1, 2), (3, 4)), ((5, 6), (7, 8))))
>>> def insert_left(tree, value)
  File "<stdin>", line 1
    def insert_left(tree, value)
                               ^
SyntaxError: invalid syntax
>>> def insert_left(tree, value):
...   if type(tree) is TupleType:
...     return (tree[0], insert_left(tree[1], value))
...   else:
...     return (tree, value)
...
>>> print tree
(((1, 2), (3, 4)), ((5, 6), (7, 8)))
>>> print tree2
((10, 11), (((1, 2), (3, 4)), ((5, 6), (7, 8))))
>>> tree3 = insert_left(tree2, 167)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in insert_left
NameError: global name 'TupleType' is not defined
>>> from types import *
>>> def insert_left(tree, value):
...  if type(tree) is TupleType:
...   return (tree[0], insert_left(tree[1], value))
...  else:
...   return (tree, value)
...
>>> tree3 = insert_left(tree2, 4643)
>>> print tree3
((10, 11), (((1, 2), (3, 4)), ((5, 6), (7, (8, 4643)))))
>>>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List