From: Reuben T. <rr...@sc...> - 2004-02-04 17:15:34
|
> Not especially, e.g.: > > list = { h = "Item 1", t = { h = "Item 2", t = { h = "Item 3", t = nil }}} > > Insertion at a random point in such a structure is O(1) if you've already > found that point, whereas it's O(n) for vectors. Right-o, I was being a bit dense. > Trees also have their advantages at times (e.g. when keys are complex, > since 'equal' Lua tables don't hash the same, or simply as a compromise > between lookup and ordered insert speed). Just because we have this > built-in hash-table doesn't mean that other classic data structures > don't have their uses, and standard libraries for other langauges tend > to implement them. Although there's usually only any point in Lua for efficiency grounds. I've never needed to implement anything else (although trees, as well as lists, don't really need "implementing", you can just use keys 1 and 2 for head and tail or left and right). > Well yes, but I don't think you would want all tables being vectors by > default, so arg would need to be treated separately. I see... > Yes, and also it should be possible to avoid building lists, concatenating > them, then unpacking them, as in e.g. bind(). Are there primitives that could be used in Lua here? i.e. without having to implement even a few core functions in Lua, but just by allowing Lua more access to...I dunno, tuples? > I think the Lua authors argument is that it is much harder to mess about with > binary modules, so for simple stuff it's best if you don't have to, whereas > it's very easy to download Lua code separately and dofile() it. True but somewhat missing the point. There's a big difference in most people's minds between stuff that's the standard distribution (gets under the Not Invented Here barrier) and stuff that isn't. > Python and Smalltalk have copy and deepcopy That might be better than copy and clone? At least makes sense to some people. But thinking genetically "clone" makes sense as deep copy. -- http://www.mupsych.org/~rrt/ | violence, n. bravery for cowards |