From: Alan W. I. <ir...@be...> - 2002-02-19 21:51:58
|
I have been struggling with resetting the cmap1 to default values for tcl. Turns out my problems were due to the following construct which I thought should work to initialize the matrix. matrix l f 6 = {0.5, $midpt, $vertex, $vertex, $midpt, 0.5} This silently fails by sticking zeroes everywhere there is a variable reference (i.e., all the interior points) even though the variables have previously been set. Isn't this a bug? Shouldn't the variables just be replaced by their values? I worked around this by using l 1 = $midpt l 2 = $vertex etc., in x08.tcl, but I don't think this workaround should be necessary. Alan email: ir...@be... phone: 250-727-2902 FAX: 250-721-7715 snail-mail: Dr. Alan W. Irwin Department of Physics and Astronomy, University of Victoria, P.O. Box 3055, Victoria, British Columbia, Canada, V8W 3P6 __________________________ Linux-powered astrophysics __________________________ |
From: Geoffrey F. <fu...@ga...> - 2002-02-19 22:00:16
|
Alan W. Irwin writes: > I have been struggling with resetting the cmap1 to default values for tcl. > Turns out my problems were due to the following construct which I thought > should work to initialize the matrix. > > matrix l f 6 = {0.5, $midpt, $vertex, $vertex, $midpt, 0.5} > > This silently fails by sticking zeroes everywhere there is a variable > reference (i.e., all the interior points) even though the variables have > previously been set. Isn't this a bug? Shouldn't the variables just be > replaced by their values? > > I worked around this by using > > l 1 = $midpt > l 2 = $vertex > > etc., in x08.tcl, > > but I don't think this workaround should be necessary. :-). It's called "Tcl" because you're supposed to giggle every time it annoys you. Braces protect against variable interpolation. There's probably a way to get what you want using eval or list or something. -- Geoffrey Furnish fu...@ga... |
From: Maurice L. <mj...@ga...> - 2002-02-19 22:27:21
|
Geoffrey Furnish writes: > Alan W. Irwin writes: > > I have been struggling with resetting the cmap1 to default values for tcl. > > Turns out my problems were due to the following construct which I thought > > should work to initialize the matrix. > > > > matrix l f 6 = {0.5, $midpt, $vertex, $vertex, $midpt, 0.5} > > > > This silently fails by sticking zeroes everywhere there is a variable > > reference (i.e., all the interior points) even though the variables have > > previously been set. Isn't this a bug? Shouldn't the variables just be > > replaced by their values? > > > > I worked around this by using > > > > l 1 = $midpt > > l 2 = $vertex > > > > etc., in x08.tcl, > > > > but I don't think this workaround should be necessary. > > :-). It's called "Tcl" because you're supposed to giggle every time > it annoys you. > > Braces protect against variable interpolation. > > There's probably a way to get what you want using eval or list or > something. The matrix initializer is expecting a Tcl list for input. So if you want variables expanded, use quotes, not braces. Unfortunately quotes are cumbersome for initializing a multidimensional array (if even this works; it looks like it might but I haven't tried). So ideally the initializer would call Tcl_ExprDouble or Tcl_ExprLong in order to evaluate the arguments. I'll put it on my list of things to consider in my Tcl matrix overhaul planned for later this year, but otherwise try using quotes. -- Maurice LeBrun mj...@ga... |
From: Alan W. I. <ir...@be...> - 2002-02-19 23:55:25
|
On Tue, 19 Feb 2002, Maurice LeBrun wrote: > The matrix initializer is expecting a Tcl list for input. So if you want > variables expanded, use quotes, not braces. Single quotes failed, but double quotes succeeded so I am a happy camper now. (Or should I say I am Tcled pink?....;-)) Thanks, Maurice! (Also thanks to Geoffrey for starting punning....) Alan |
From: Maurice L. <mj...@ga...> - 2002-02-20 03:07:04
|
Alan W. Irwin writes: > On Tue, 19 Feb 2002, Maurice LeBrun wrote: > > > The matrix initializer is expecting a Tcl list for input. So if you want > > variables expanded, use quotes, not braces. > > Single quotes failed, but double quotes succeeded so I am a happy camper now. Single quotes.. who uses those? Oh yeah, Fortran... ;) -- Maurice LeBrun mj...@ga... |
From: Alan W. I. <ir...@be...> - 2002-02-20 04:06:52
|
On Tue, 19 Feb 2002, Maurice LeBrun wrote: > Single quotes.. who uses those? Oh yeah, Fortran... > > ;) ;-) However, in the interests of historical accuracy I gotta say the point was moot for my first Fortran compiler in 1968. The only string that sucker had was the one wrapped around the "PDQ compiler" card deck. Before each task that deck was read into the machine, then your fortran source on cards was read into the machine. That produced an object code deck which was then read into the machine and executed. I still remember the great joy we all had when we upgraded to an IBM 1130 that actually had a disk-resident fortran compiler which would save your object code to disk and execute it without fiddling with Fortran compiler object decks or your own object deck. It was a year later in graduate school that we got access to a fortran compiler that could deal (to a small extent) with character strings. I wonder whether the next 30 years in computing will have so many revolutionary changes as the last 30 years? I sure hope so! Alan |