You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std should collect api functions that are not specific to a given module #68
Having separate std.list.elems, std.table.ielems, std.set.elems is repetitive and unidiomatic. Instead, these kinds of functions should be collected in a new std.lua module such that a single std.lua.ielems will iterate over any list-like argument (either a raw table, a List or a custom object with an __ipairs metamethod.
The per-module variants can then be deprecated and eventually removed.
Do we still want list:elems () etc? I'm leaning strongly towards deprecating those too, after all, core Lua doesn't proliferate methods such as table:ipairs ().
changed the title [-]std.lua contains language features that are not specific to a given module[/-][+]std.lua should contain language features that are not specific to a given module[/+]on Jul 17, 2014
I've decided that I will deprecate the superfluous object method variants of iterators.
So far I've collected elems, pairs, ielems, ipairs and ripairs into a new std.lua module. If we have ripairs I should probably also add rielems, though I'm strongly leaning towards replacing ripairs with the more composable ireverse, which would eliminate the need for std.list.reverse and make implementation of ripairs and rielems trivial one-liners:
I'll take care to respect __ipairs on Lua 5.1 with ireverse too. Which, in turn, makes the (IMHO) ill-conceived totable/__totable idioms redundant. Writing a complex object that behaves like a raw table (by hiding or generating some key/value pairs, say) can be achieved with existing machinery: i.e. __ipairs or __pairs.
In the vein of collecting high-level functions into the top-level std namespace, now, I just need to figure out what to do with the type vs. prototype mess I created: Ideally, a single std.type function would be the only api, taking the place of std.object.prototype and variants -- however, it's often useful to be able to recognize a primitive table, whether or not it happens to also have a _type field.
Possibly, an optional second :primitive argument would fix those kinds of issues, and I'm sure by the time I implement #62, that will become a spurious stop-gap that can be removed... except that I'll have already used it all over the place by then and cleaning up will be a big time waster.
Alternatively, I could close this issue, and leave a pointer to it in #62, fully expecting it to come out in the wash by then without any more code churn.
changed the title [-]std.lua should contain language features that are not specific to a given module[/-][+]`std` should contain language features that are not specific to a given module[/+]on Jul 25, 2014
changed the title [-]`std` should contain language features that are not specific to a given module[/-][+]`std` should collect api functions that are not specific to a given module[/+]on Jul 25, 2014
Activity
[-]std.lua contains language features that are not specific to a given module[/-][+]std.lua should contain language features that are not specific to a given module[/+]gvvaughan commentedon Jul 21, 2014
I've decided that I will deprecate the superfluous object method variants of iterators.
So far I've collected
elems,pairs,ielems,ipairsandripairsinto a newstd.luamodule. If we haveripairsI should probably also addrielems, though I'm strongly leaning towards replacingripairswith the more composableireverse, which would eliminate the need forstd.list.reverseand make implementation ofripairsandrielemstrivial one-liners:I'll take care to respect
__ipairson Lua 5.1 with ireverse too. Which, in turn, makes the (IMHO) ill-conceivedtotable/__totableidioms redundant. Writing a complex object that behaves like a raw table (by hiding or generating some key/value pairs, say) can be achieved with existing machinery: i.e.__ipairsor__pairs.gvvaughan commentedon Jul 21, 2014
Now that I think about it,
std.luashould be an implementation detail, and its functions should be exported fromstdfor a more pleasant api:(Of course
std.monkey_patchwill scribble these into the global namespace as necessary)gvvaughan commentedon Jul 25, 2014
All but finished.
In the vein of collecting high-level functions into the top-level
stdnamespace, now, I just need to figure out what to do with thetypevs.prototypemess I created: Ideally, a singlestd.typefunction would be the only api, taking the place ofstd.object.prototypeand variants -- however, it's often useful to be able to recognize a primitive table, whether or not it happens to also have a_typefield.Possibly, an optional second
:primitiveargument would fix those kinds of issues, and I'm sure by the time I implement #62, that will become a spurious stop-gap that can be removed... except that I'll have already used it all over the place by then and cleaning up will be a big time waster.Alternatively, I could close this issue, and leave a pointer to it in #62, fully expecting it to come out in the wash by then without any more code churn.
Thoughts?
[-]std.lua should contain language features that are not specific to a given module[/-][+]`std` should contain language features that are not specific to a given module[/+][-]`std` should contain language features that are not specific to a given module[/-][+]`std` should collect api functions that are not specific to a given module[/+]