[LLVMdev] Enhancing TableGen

David A. Greene greened at obbligato.org
Tue Oct 11 14:27:51 PDT 2011


Jakob Stoklund Olesen <stoklund at 2pi.dk> writes:

>> but that requires another keyword.  Do we care?
>
> The syntax should be consistent with let expressions, even if the meaning is completely different.
>
> That is: "foreach x = […] in { def … }"

Ok, that sounds good to me.

>>> Another thing that needs clarification is the multiple variable
>>> syntax:
>>> 
>>>  for x = [1, 2, 3], y = [4, 5, 6] in { … }
>>> 
>>> It is not clear if you get a cross product or a 'zip'.
>> 
>> Che-Liang proposed a zip and I think I like that.
>
> Yes, we definitely need to do a zip.
>
> I was looking for a syntax that makes it clear what is happening.

Ah, gotcha.  Off the top of my head, something like this might convey
things well and I think it will fall out in the parser fairly well too:

foreach [x, y] = [ [1, 2, 3], [4, 5, 6] ] in { ... }

But that might be too cutesy.  Double-list notation can get ugly.

Maybe

foreach {int x, int y} = { [1, 2, 3], [4, 5, 6] } in { ... }

or 

foreach {int x, int y} = [1, 2, 3], [4, 5, 6] in { ... }

Slightly better?  Declarations pretty much have to be part of this to
avoid use-before-declaration problems.

                         -Dave




More information about the llvm-dev mailing list