[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inferno and limbo discussions



	is it possible to turn a tuple into a scalar in a single expression.

no, although you could say

  (div, nil) := divmod(x, y);

(using nil as a throwaway l-value) to extract just the div part.
===

	do guarded alts work correctly ?

	e.g.

	  wait(waitforoutput, waitforinput : int, chin, chout : chan of int)
	  {
	    alt
	    {
	     waitforoutput && chin <-= 99 =>
	                          sys->print("sent value");
	     waitforinput && val := <-chout =>
	                          sys->print("val received: %d\n", val);
	    }
	  }

this doesn't work.  the manual doesn't explain well the properties of
guards in alt statements.  as written, this code is illegal.  a legal
rewrite is:

wait(waitforoutput, waitforinput : int, chin, chout : chan of int)
{
    alt
    {
	waitforoutput && (chin <-= 99) =>
		sys->print("sent value");
	waitforinput && (val = <-chout) =>
		sys->print("val received: %d\n", val);
    }
}

however the execution is not what you'd expect.  the alt statement
evaluates the communications for completability; the chosen communication
will then be run.  finally, the rest of the expression will be evaluated, so the
waitforinput guard does not protect the communication, only the execution
of the action.
===
	quote :
		"An uninitialized string, or one set to nil, is identical to
		the empty string (denoted "") for all the relational operators"

	  also

		"A non-initialized string, or one whose value has been set to
		nil, compares equal to nil. (This is different from the
		zero-length string, which is denoted "")."

	  these statements seem to conflict. which one is true ?

They do conflict; the parenthesized expression is erroneous.  The strings
"" and nil are equivalent.

===
	conversion from lists to arrays

there is no automatic conversion between lists and arrays

===

	slice expressions

	  how is aliasing avoided (or is it) ?

slices are a way to develop aliases for use like pointers.

	  copybytes(to : array of byte, from : array of byte, count : int)
	  {
	    for (i := 0; i < count; i++)
	      to[i] = from[i];
	  }

	  ...
	  x := array[20] of byte;
	  b, c : array of byte;

	  b = x[10:15];
	  c = x[11:16];

	  copybytes(b, c, 5);

this is legal; but so is this:

	x[10:] = x[11:16];

and this last form is far more efficient in general.

===

	for what reason does the function srv->reads() exist ?

it's a historical dreg and should be dropped.

===
	how possible would it be to implement inferno on a
	non-shared-memory multiprocessor machine ?

there is no short answer to that question.

===

	why are all adt members visible by default, and doesn't
	this make interface upgrades more difficult, as the whole
	type is visible to all clients of that type ?

limbo is intended to be a simple language.  the issue of maintenance
is helped by the module type-checking at load time being applied only
to those portions of the interface used by the client of the module, so
a module may be extended backward-compatibly.


-rob pike