mattunlv / ProcessJ-main-branch-old

ProcessJ Compiler Project
2 stars 4 forks source link

Extracting channel end array from a channel array... #7

Open cabelshrestha opened 7 years ago

cabelshrestha commented 7 years ago

consider:

chan<boolean> up[] = new chan<boolean>[5];
chan<boolean> down[] = new chan<boolean>[5];

what do I do if I now wanna pass all the reading ends of up to a procedure that takes in an array of reading ends?

f(up, down)

is not right cause that is passing entire channels….so what about

f(up.read, down.read)

but that is the reading end of an array ….. that makes no sense either …

I am thinking that we should allow array.read to be an array of read ends …

matt

cabelshrestha commented 7 years ago

more good stuff: this dies too:

public proc void guard(chan<boolean>.read[] up,
                       chan<boolean>.read[] down) [yield=true] {
  int seated = 0;
  boolean any;
  while (true) {
    alt {
      any = down[0].read(): {
        seated++;
      }
    }
  }
}

matt

cabelshrestha commented 7 years ago

@mattunlv I'm assigning this to you for now. Are we decided on adding array.read to the grammar? If we are and once you are done, you can pass this on to me.

mattunlv commented 7 years ago

I have added this but can't test it cause of the issue I just opened a case about.

Matt

cabelshrestha commented 7 years ago

Dr. Pedersen comment:

So I was thinking about this:

chan[] chans = new chan[100];

chans.read <---- that is currently illegal.

However, that is just a type checking trick

chans is of type Array(Chan), but chans.read is of type Array(ChannelEndRead)

so I just need to fiddle around with building a new type but you STILL need to pass in the same cause

chans and chans.read and chans.write for YOU is the same as channels in the runtime are not by end but by the entire channel.

;-) that makes that easier

Matt