lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great dyngeccetor8 once stated:
> On 07/31/2018 12:00 AM, Sean Conner wrote:
> > [...]  I line up sequential
> > assignments in my code:
> > 
> > 	local iostream =
> > 	{
> > 	  close     = close,
> > 	  flush     = flush,
> > 	  lines     = lines,
> > 	  read      = read,
> > 	  seek      = seek,
> > 	  setvbuf   = setvbuf,
> > 	  write     = write,
> > 	  
> > 	  _readf    = accumulate_data,
> > 	  _readbuf  = "",
> > 	  _writebuf = "",
> > 	  _sock     = conn,
> > 	  _remote   = remote,
> > 	  _pollset  = nfl.SOCKETS,
> > 	  _eof      = false,
> > 	}
> > 
> >   That works for me; it probably doesn't work for anybody else.  That's my
> > habits from Assembly language past showing here.
> 
> Good luck with renaming field to identifier with different length.

  Oh, I am fully aware of the downsides and am willing to live with the
results.  LIke I said, it works for me, probably not for everybody but I'm
not the one saying "I'm doing it right; all'y'all are doing it wrong."

> Looks like we're off-topic here and just criticizing others habits
> while showing ours. So lets continue!
> 
> I've discovered my median Lua chunk size is about 12 lines (with 70
> chars limit and 2-space indent). That's to talk about "screens".

  I don't bother with function length, it takes as long as it takes (some
three lines of code, I have one that is 637 lines long, but it's valdiating
a message with a ton of comments about each validation (with links to
trouble tickets, standards, references, etc).  I have no idea what my
average length of function is.  

As far as width goes, I try to keep it under 78 characters, but I don't
stress about it.  If a line gets to about 90+ or so, I'll probably break it
up across multiple lines.

> I use upvalues mostly in recursive functions (where you can't call
> itself without previous declaration).

  With the Y-combinator you can:

	function Y(f)
	  local function g(...) return f(g,...) end
	  return g
	end

	print(Y(function(rec, x) if x < 2 then return 1 else return x * rec(x-1) end end)(5))

> And separate almost any "function" statement as separate module.
> That is why I was need relative require().

  I'm not sure I understand this.

  -spc