Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Latch concept is probably worth exploring further. Does anyone know of a language with native variables being a FIFO pipe? I.e.

  x = 1   // x now contains 1
  x = 2   // x now contains 1 and 2
  y = x   // x now contains 2, y now contains 1
  ...
This sort of thing. Not as an add-on construct, but as a native part of the language.


go channels are like that (im a little rusty but it works pretty much like this).

c := make(chan int, 2);

c <- 1;//c contains 1

c <- 2;// c contains 1 followed by 2

y <- c;//y=1


It looks like make(chan int, 2) creates a channel with a maximum depth of two elements. I was curious how channels work, so I looked up the relevant part of the spec (http://golang.org/doc/go_spec.html#Channel_types). In case anyone else was wondering, specifying the length of a channel allows it to be written and read asynchronously until the channel is full. A zero-length channel will block until both a sender and receiver access the channel.


Not "native variables", but any concurrency package built on CSP does this. For languages where it is more built in, consider Erlang or Occam.


VHDL, a hardware description language can be used in the dataflow style and models the parallelism found in hardware.


Easy enough with Perl arrays using push and shift.


With the added bonus that Perl makes it obvious you're talking about an array.


Go channels?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: