From the because-I-can department... Friday evening operator abuse.

From the because-I-can department... Friday evening operator abuse.

var
  values: Tuple;
  i: integer;
  s: string;
begin
  values := Tuple.From(42, 'foo');

  Tuple.Tie(i, s) <= values;

  WriteLn(i, ', ', s); // 42, foo
end;

or if you don't need 'em all..

procedure Test;
var
  tup: Tuple;
  s: string;
begin
  tup := Tuple.From(42, 'foo');

  Tuple.Tie(Ignore, s) <= tup;

  WriteLn(s); // foo
end;

Comments

  1. waaait, what?!

    Tuple.Tie(i, s) <= values; // <= could be then used for implementing channels much like in golang!!

    ReplyDelete
  2. David Heffernan Well not like it's non-trivial to add more elements, just didn't feel like typing that much right now :)

    ReplyDelete
  3. Dorin Duminica​ Interesting thought...

    Here's the code, keep in mind it's Friday evening quality :)

    http://paste.ie/view/e87e7a31

    ReplyDelete
  4. 404 not found on that link, looks interesting!

    ReplyDelete
  5. Willem Weideman Fixed the link... weirdly some characters had been appended to the link itself which was not visible in the G+ post.

    ReplyDelete
  6. Asbjørn Heid probably the Unicode UTF-8 BOM. Chrome does that every now and then in G+.

    ReplyDelete
  7. Dorin Duminica Never used channels, in Go or otherwise... you were thinking something along these lines? http://paste.ie/view/193bdf54

    ReplyDelete
  8. That's it!!

    Now, if the channel would be generic... (;

    ReplyDelete
  9. Dorin Duminica Generic in what sense?

    ReplyDelete
  10. Asbjørn Heid nevermind, I didn't notice Channel for some weird reason, great job!

    ReplyDelete
  11. Dorin Duminica Ah, yes that's why I was confused :) I'll brush up the code a wee bit and post it later today.

    ReplyDelete
  12. Dorin Duminica So this is just proof of concept, may have some deadlocks or race conditions etc, but hey :) It's not rocket science, but threading is hard(tm) etc.

    Also couldn't think of any nice syntax for non-blocking operations... have to think a bit about the alternatives...

    https://www.dropbox.com/s/8pfgfqugsisy17q/ChannelTest.zip?dl=0

    ReplyDelete

Post a Comment