[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal: allow @, $, !, and ? in Lua identifiers
- From: Sean Conner <sean@...>
- Date: Fri, 25 Apr 2014 15:33:28 -0400
It was thus said that the Great Coroutines once stated:
> I'd like to discuss allowing @, $, !, and ? in identifier names. I
> chose these explicitly because they can't be confused with an operator
> at the end of an identifier.
>
> >From what I understand, it's common practice in Ruby and Lisp to write
> methods like this if you intend they return a boolean:
>
> empty?(some_table) -- returns true if some_table is empty
>
> Usually is_empty() is what I see people use because it's clear that
> the function is testing for emptiness and not emptying the table.
>
> The problem is you sometimes wind up writing this terrible thing: if
> not is_empty(tbl) then ... end
>
> Ruby also makes it convention to put ! at the end of the function name
> if if modifies its `self'. The non-! version returns a modified copy.
>
> I feel like these 2 added characters alone would make it much easier
> to express semantic in function names.
>
> @ could be used if a function creates an object that internally
> references the object it was created from, so you'd know whether to
> copy or deep-copy later.
>
> I'd propose using $ if a function has side-effects, or performs some
> form of I/O -- but I'd love to hear other ideas. I've never seen $
> used except as an operator in Haskell -- the expression on the
> right-hand side gets evaluated and passed to the expression on its
> left-hand side. What could it mean as part of a function name?
function panic!!!!(message)
print@(screen.width/2,screen.height/2,message)
sys$wait("5s")
why_must_i_die?("now")
end
-spc (If you want to enforce a convention, make it part of the langauge)
- Prev by Date:
Re: Proposal: allow @, $, !, and ? in Lua identifiers
- Next by Date:
Re: Proposal: allow @, $, !, and ? in Lua identifiers
- Previous by thread:
Re: Proposal: allow @, $, !, and ? in Lua identifiers
- Next by thread:
Re: Proposal: allow @, $, !, and ? in Lua identifiers
- Index(es):