lua-users home
lua-l archive

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


On Fri, Aug 22, 2014 at 3:33 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-08-22 12:02 GMT+02:00 Coroutines <coroutines@gmail.com>:
>
>> I've been working more in Javascript lately
>
> You have my sympathy. I'm so sorry for you that I won't even
> say anything nasty about your remark that:
>
>> I'd much rather see type('cat') == 'userdata'.

I've always been a fan of schenarios like: string.__type = function
(self) return original_type(self), 'string' end

local obj_type, obj_subtype = type('cat') -- 'userdata', 'string'

In my opinion, it would be nicer to stop pretending string is anything
other than "subclassed" from userdata.  The only "raw" types that
should exist are: nil, boolean, number, function, table, coroutine,
and userdata :p  -- and I'm pretty sure coroutines could be
represented as functions or vice-versa.  Python lets you yield from
any of its functions :p

Anyway, Javascript will never be as nice as Lua -- but I often think
about ways in which we can organize the fundamentals of Lua better.
I'm no expert, but this is where that thinking has led.  The mechanics
of Lua's string handling could be scripted from in Lua, and imo it
would be cleaner to do so.  Lua is very fast, but I think I'd be much
happier seeing the standard libs written in Lua directly (and the
string type) -- so that it's more accessible and "hackable" for those
embedding Lua.

I'll see myself out... lol.