Re: [Wrapl-discussion] list:delete, list:remove
Brought to you by:
rajamukherji
|
From: Roman M. <rom...@gm...> - 2010-09-03 11:25:09
|
Hi :) TO :puzzle(list @ List.T) ALL PROD list:copy:delete(list:keys):values; A silly example, perhaps. And this version, probably, won't work (given two generators). I want to show that such a long construct makes a kind of data-flow with list data. I can terminate it where I want (i.e., I transform the structure and then - stop, at this point I want to get its :values). But :delete' behaviour breaks that flow. That is unexpected - partially because it is not in line with other list methods, and partially because I didn't intend to get the value(s) at this point. And there are no methods to delete, returning a list. Obviously, there are cases where the list is desirable as well as cases where the value is. WITH removed_item <- cache:remove(items_by_date()) DO (...); WITH item <- cache:find(items_by_date()) DO (... => cache:delete(item)); Would you agree that cache resembles a stack-like structure? With the stack style it is expected (IMO) to get the value when it is removed. Would it be an option then to have additional :drop and :pick (or :peek) stack-style methods that behave like current :delete and :remove do, but put :delete and :remove in line with other list-style methods and with Table module and have them return the list. I mean there already are two kinds of behaviour in List module: stack-style and list-style (:push, :put) == :insert; (:pop, :pull) == :delete; I propose to have (:pop, :drop, :pick, :pull) == (:delete, :remove) equivalence, were: :drop(list @ T, n @ Std.Integer.SmallT) : ANY - takes index and returns value; :pick(list @ T, value) : ANY - takes value and returns value; :delete(list @ T, n @ Std.Integer.SmallT) : T - takes index and returns list; :remove(list @ T, value) : T - takes value and returns list; I do not know how this affects your code and you could argue the names. |