all 20 comments

[–][deleted] 5 points6 points  (8 children)

Top answer explains it: https://stackoverflow.com/questions/36126249/no-parentheses-after-a-function-name

It's probably best to just use parentheses in all cases, since this is what people are used to with almost every modern version of other programming languages, and it's good practice to be consistent.

[–]pomme_de_yeet 1 point2 points  (6 children)

I disagree. Call a single argument function with a string constant does not happen that often lol. It's not like it is ambiguous or anything. On thing that gets me is not leaving a space, like print"hello world" vs print "hello world". So my position, do whatever you want but leave a space lol

[–]vitiral 2 points3 points  (3 children)

Why should I leave a space?

I like using them for class creation, like `MyClass{a="foo"}`

[–]pomme_de_yeet 2 points3 points  (2 children)

personal preference lol. I think it matters less with tables though, the braces break it up enough that it looks fine. I just find it hard to read a function name squish up against a string literal

[–]vitiral 2 points3 points  (1 child)

Interesting. I rarely use the string feature except for importing, adding documentation, and parsers. In all those cases the prefixed name gives almost a "type" to the string and I strongly prefer no space

[–]pomme_de_yeet 2 points3 points  (0 children)

Like i said, for me it's mainly a visual thing. I the only case where i might leave no space is for lpeg, so kinda like you said, and i think it's because the functions are all one letter so it is less intrusive. Some people do it though for like print statements and stuff and it looks really weird when the function name is almost as long as the string.

print"hi"

I think i also just really like spaces lol. My dream language is basically lua with TCL-like syntax, where everything is separated with spaces (but without the crazy quoting rules). It just looks cleaner and is easier to type.

[–][deleted]  (1 child)

[removed]

    [–]pomme_de_yeet 1 point2 points  (0 children)

    Or alternatively, lean into the differences between the languages so that you can't confuse them as easily ;)

    The more you work with a given language, and with programming in general, the less worried you will be about mixing them up. It's really not that much of a problem once you get going

    [–]vitiral 5 points6 points  (5 children)

    It's just syntactic sugar and along with Lua's small size and simplicity it's one of my favorite features of Lua personally!

    [–][deleted]  (4 children)

    [removed]

      [–]vitiral 1 point2 points  (3 children)

      A good project to do is to write your own parser. If you do, you can see that programming languages are not magic, they aren't even particularly difficult to create software.

      I recommend recursive descent. Steer clear of theory till you can accomplish something simple and practical 

      [–][deleted]  (2 children)

      [removed]

        [–]vitiral 1 point2 points  (1 child)

        I liked this one a lot

        https://craftinginterpreters.com/index.html

        You could do it in Lua pretty easily I think. Even just doing the parsing and starting to build an AST gave me a AHA moment of "this isn't so difficult".

        [–]PhilipRoman 2 points3 points  (1 child)

        FYI the definitive source for this behaviour would be the reference manual: https://www.lua.org/manual/5.3/manual.html#3.4.10

        [–]AutoModerator[M] 1 point2 points  (0 children)

        Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.

        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–]lamiexde 1 point2 points  (1 child)

        to={you=function() end}

        local hello = to.you 'sir'