Array Redux

Strange how my thoughts turn to BOOL in the early part of even-numbered years. (I wonder if it has something to do with the San Francisco Giants baseball team, although I don’t know why, and I’ve been hitting even-numbered BOOL version years longer than they’ve been winning World Series, plus I hope they don’t win this year.)

But in any event, I found myself pondering the *array type (again)…

After just now re-reading the previous (“final”!) decision about array syntax, I like the rationale and will probably stick with it, but here’s another hat to toss in the ring (maybe in writing this post, the matter will settle in my mind).

*array <*int>  Board/10/10
set: Board/0/0 42

The change involves how to specify dimensions and how to access members. The same logic applies to user-defined types with regard to access:

.   *int  x =0
.   *int  y =0

*point p1
set: p1/x 42

Another possibility involves commas:

*array *int  Board,10,10
set: Board,0,0 42

That version also illustrates the idea of leaving off the angle brackets. The syntax needs to accommodate the possibility of something after the Model name. With the angle brackets, it’s a binding; without them, it’s just a Model name.

(To be honest, the binding does sound better. We already have the idea that a binding can follow certain declarations. OTOH, all others are definitions! Here we’re dealing with an instance. OTOOH, a binding still makes more sense.)

The other thing is that I’m not entirely comfortable with how the label syntax is used here. Feels like overloading of the square brackets, which are crucial in the list syntax.

The use of commas has the rationale that an object’s name can be just the name, or it can be a list. If it’s a list, then the first item is the object name, and the other members of the list specify some part of the object.

The slashes offer the same basic idea, but don’t overload the implicit list comma operator. (In some regards, I kind of like the list idea, but I’m not sure I like the use of commas as (effectively) “select” operators.)

I’ll have to write some BOOL code using the various options to see which one looks best:

*array <*int>  Board/10/10

set: Board/0/0 WHITE-ROOK
set: Board/0/1 WHITE-KNIGHT
set: Board/0/2 WHITE-BISHOP
set: Board/0/3 WHITE-KING
set: Board/1/0 WHITE-PAWN
set: Board/1/1 WHITE-PAWN
@if eq:Board/3/6 BLACK-QUEEN
.   @print "She's Here!"


*array <*int>  Board,10,10

set: Board,0,0 WHITE-ROOK
set: Board,0,1 WHITE-KNIGHT
set: Board,0,2 WHITE-BISHOP
set: Board,0,3 WHITE-KING
set: Board,1,0 WHITE-PAWN
set: Board,1,1 WHITE-PAWN
@if eq:Board,3,6 BLACK-QUEEN
.   @print "She's Here!"

For the moment, I’m leaning commas (and I do like the rationale). The question, I suppose, is whether object names being lists sits well.

%d bloggers like this: