From: Vladimir Konrad Date: 2007-01-30T06:20:48+09:00 Subject: Re: Working with the parse tree in Ruby? > Martin, in addition to what Aaron has written, I'd like to ask you what > you need this for. I've been playing with implementing macros in Ruby a > few times, but I found no compelling reason to support them in Ruby. well, i have a use case (but this is doable, i think, with existing ruby using code generation and eval). i wanted to write a "universal netcdf dump" procedure for netcdf files (the netcdf library for ruby exists). the format i have has few dimensions and one multi-dimensional array. the problem is that the number of dimensions can vary - e.g. you can have value(dim1) or value(dim1,dim2,dim3...). what i wanted was a general way to dump the multidimensional variable value + each related value in each dimension as a table for import to SQL. this translates to nested iterators (where number of iterators is the number of dimensions) e.g for 2 dimensions something like: # this is pseudo code, dim1, dim2, value are arrays from netcdf dim1[].length.times{|dim1_i| dim2[].length.times{|dim2_i| print dim1[dim1_i], dim2[dim2_i], value[dim1_i,dim2_i] }} i could not imagine to do this without a macro (or without code generation and eval). vlad ps: i have not done the "universal netcdf dump" procedure as i do not really need it for the import but it was an interesting thing to think about . -- Posted via http://www.ruby-forum.com/.