Eigenstate: myrddin-dev mailing list

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

Re: union member already defined?


On Sun, 29 Jul 2018 20:50:28 +0900, theos <theosjp@xxxxxxxxx> wrote:

> hi iriri -
> 
> thanks for the hello and welcome.  yes, i find what you guys have been
> putting together really amazing.

Thanks. :)

> regarding the union - hmm... interesting.  i've had noticed that the
> code compiled when i made the tags unique, but i thought that this cant
> be right.
>
> do you know what the motivation was to scope it this way compared to c?

In addition to what iri said, the way that unions are constructed is:

	var u = `Uniontag val

And the unions values are extracted by pattern matching
like so:

	match u
	| `Uniontag v:	std.put("v")
	;;

So, without enforcing uniqueness, it would be impossible to
know which union was referred to.

And, honestly, the 'std.' in union lookups is annoying enough:

	match fn()
	| `std.Ok result:	use(result)
	| `std.Err error:	fail(error)
	;;

Turning it into:

	match fn()
	| `std.result(mytype).Ok result:	use(result)
	| `std.result(mytype).Err error:	fail(error)
	;;

didn't seem appealing. I think that a very early attempt used
to do this, but I can't remember if I ever committed it, or
whether I just mocked up some code, decided it was clunky,
and ditched it.

> thanks,
> theo



-- 
    Ori Bernstein

Follow-Ups:
Re: union member already defined?theos <theosjp@xxxxxxxxx>
Re: union member already defined?Ryan Gonzalez <rymg19@xxxxxxxxx>
References:
union member already defined?theos <theosjp@xxxxxxxxx>
Re: union member already defined?iriri <iri@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Re: union member already defined?theos <theosjp@xxxxxxxxx>