Path: utzoo!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer From: goer@ellis.uchicago.edu (Richard L. Goerwitz) Newsgroups: comp.lang.icon Subject: Re: Multiple value assignment in icon??? Message-ID: <1991Mar18.150838.24597@midway.uchicago.edu> Date: 18 Mar 91 15:08:38 GMT References: <1991Mar13.180536.22613@cl.cam.ac.uk> <1991Mar15.013415.1499@midway.uchicago.edu> <1991Mar16.142726.5947@cl.cam.ac.uk> Sender: goer@midway.uchicago.edu (Richard L. Goerwitz) Organization: University of Chicago Lines: 58 Bdb@cl.cam.ac.uk (Brian Brunswick) writes: >> >> val := create f() >> every (x|y) := @val > >Yup, I'd spotted that this was possible, but was put off by the extra >temporary variable needed - I'd really like something on one line.... You know, I've never understood peoples' resistence to side-effects of this kind in Icon. All your garbage gets collected for you, and you are not going to have any problems with pointers. The variables, if declared explicitly local, aren't going to conflict with anything else. If they make the code clear and idiomatic, then my own vote is to use them! >Hmm... I'm not so sure that I don't prefer my cludge to having to >introduce an extra intermediate variable. Of course, its only good so >long as its clearly recognised as an idiom by the reader, otherwise >its needless obfuscation. I guess that's what I was trying to say. >Also, I hesitated somewhat at creating a co-expression just to do >something that short that I'm likely to use quite a lot. Isn't that >likely to be quite expensive in terms of garbage produced? Or would >reusing the same temporary to hold it mean that reference counting or >something rescues things? You know, I really don't know. Co-expressions involve less overhead than a procedure call, as I understand them, and are a bit faster. If storage and garbage collection is a problem, you could try writing two versions of the program, and then check out the IPL program empg.icn. It's a tool that's ideal for just this kind of profiling. You could also write a little shell script to turn on memory monitoring, and then use the IPL routine memsum to get a summary of the results. I'm thinking of, say, #!/bin/sh if test $# = 0 then echo 'usage: memmon icon-program [arguments]' exit 1 else export MEMMON MEMMON=tablc.mon $* # unset MEMMON /usr/local/bin/memsum < tablc.mon > tablc.sum /bin/cat tablc.sum | egrep -v '0.000$' 1>&2 /bin/rm tablc.mon tablc.sum fi I'll be curious to hear what you eventually settle on. -Richard (goer@sophist.uchicago.edu)