Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-03-26 11:36:24


On Mon, 26 Mar 2001, Doug Gregor wrote:
gregod>
gregod> Yet another alternative would be to use this relational
gregod> operator syntax along with the previously-proposed idea of
gregod> multiple function call operators, except use the subscript
gregod> operator, i.e.,
gregod>
gregod> A[1][0 <= stride(2) < 10][5]

This certainly would be nice, but it has some weird consequences.

Does the expression "A[0<=stride(2)<10]" mean:

1) return a subarray of A, where subarrays have the exact
 same semantics as arrays.
2) return a subarray of A, where subarrays include a
 dimension counter which says which dimension to apply
 the next subscript operator.

If we choose 1)
  "A[3<=stride(1)<10][2]" is equivalent to "A[5]" because
  the "[2]" still applies to the outer dimesion, and since 3+2=5.
  This is obviously not what you meant to happen.

If we choose 2) we get the intended behaviour for
  "A[3<=stride(1)<10][2]" but now we have subarrays with
  different semantics than arrays. For example, the expression
  "B[0<=stride(1)<5]" will have a different meaning depending
  on whether B is an array, or if it is a subarray. Imagine
  calling a function which takes an array argument. The
  function would do very different things depending on
  whether you passed an array or subarray. I suppose we
  could have some function that resets the subscript
  dimension counter, but this seems dangerous.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk