lua-users home
lua-l archive

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


> > - Always use as many warnings as feasible (and fix all warnings).
> 
> Oh, good gods, please don't go that far.

	fea·si·ble  (fē′zə-bəl)
	adj.
	[...]
	3. suitable: a road feasible for travel. 

	suit·a·ble  (so͞o′tə-bəl)
	adj.
	Appropriate to a purpose or an occasion.


> > - Avoid implicit "multi-step" type conversions (e.g., float ->
> > unsigned char).
> 
> What's multi-step about that?  Are you talking about the default
> arithmetic conversions converting float to double before that goes to
> unsigned char?

The example I gave with floats was not a good one, sorry. A concrete
example we had in the past: (signed)char -> unsigned int. We can think
like this:

  (signed char)(-3)  ->  (int)(-3)  ->  (unsigned int)4294967293
  (signed char)(-3)  ->  (unsigned char)253  ->  (unsigned int)253

The first choice is the correct one, but some compilers did the second.
Just in case, it is safer to explicitly cast to int before casting
to unsigned int.

-- Roberto