+= and the like (-=, *= ...) is common in many languages, and J has the power to make it u assignwith. (] =:: (+ ".))
Thomas brings up mass string assignments, but my main motivation is CRUD data structures. Append delete update states. Something surprising to newcomers, that I support, is that J does not have a built in dictionary "object". Instead the pattern is to build your own from an array, and this can have huge performance benefits. Values can be arrays that are stacks or queues. If keys and values are numeric, and an "invalid" fill exists, then it can be implemented without boxing. But a simple key value store is to use a locale. Even if there is no standard dictionary class, you may wish to make one tailored to your application that provides an interface independent of implementation. If you need CRUD, you probably also need permanence (disk interaction), and may need multi-user/process access. While there exists functional paradigms to replace any OOP/state structure, the replacement involves passing all parameters all the time. A very simple hybrid of this approach is fixing the parameters in a (tacit) expression. One technique for fixing parameters is to declare functions in the create verb of a locale, and one advantage of tacit code is that it fits on one line (much easier to write inside other function), and you have the option of early or late binding parameters. > What is importantto me is the ease of predicting the result assign or assignwith in J need to be passed the "name of value" instead of value, and so needing access to the name is strongly indicative that the name will be updated. ----- Original Message ----- From: bill lam <[email protected]> To: [email protected] Sent: Tuesday, July 19, 2016 11:34 AM Subject: Re: [Jbeta] with effort for inplace assignment performance I do not worry about pure functional or tacit. What is important to me is the ease of predicting the result of a sequence of J sentences but assignment makes names mutable. IMO requiring an external storage to record states is already an side effect but I won't argue with you on that. Вт, 19 июл 2016, Thomas Costigliola написал(а): > Assignment is not *necessarily* side effecting. If you treat assignment as a > mapping from string keys to values and you write your program carefully then > it can still be functional. The thing to watch out for in J is that the maps > are global and update in place rather than returning a copy. Besides, almost > all J is a mix of tacit and explicit anyway so why worry about being > non-functional? > > > On 07/13/2016 09:07 PM, bill lam wrote: > > I find it very strange for tacit code mixed with copula. > > In general tacit form is functional and side effect free, so that > > composition is possible but copula is special and depends side effect. > > > > Ср, 13 июл 2016, JBeta написал(а): > > > I'd suggest a new built-in conjunction. Say 128!:6 or A: > > > > > > assignwith =: 1 : 0 > > > (y) =: u (y~ [ ]) :: ((i.0)"1) 1 > > > : > > > (y) =: x u (y~ [ ]) :: ((i.0)"1) 1 > > > ) > > > > > > assignwithC =: 2 : 0 > > > (y) =: u (y~ [ ]) :: (n"_) 1 > > > : > > > (y) =: x u (y~ [ ]) :: (n"_) 1 > > > ) > > > > > > the error checking (::) is there to set an initial value if the name > > > doesn't exist. > > > > > > 1 , assignwith (][ +: assignwith) 2 (][ , assignwith) (][erase) 'aa' > > > 1 4 > > > > > > The adverb version can be shortened to > > > > > > 1 : 0 > > > > > > (y) =: u ". y > > > : > > > (y) =: x u ". y > > > ) > > > > > > > > > which is a neat feature of ". > > > > > > An alternative to allow tacit definitions of assignments would be the > > > ordinary dyad: > > > > > > =:: > > > > > > assign =: 4 : '(x) =: y' > > > > > > the pattern ([ =:: u) or (] =:: u) would seem straightforward to "boost" > > > with special code for in place assignment. > > > > > > assignwith =: (] assign (u@:".)) : (]assign (u ".)) > > > > > > > > > I imagine this as easy and very useful, especially in combination with > > > inplace improvements. > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
