On Mon, Mar 19, 2018 at 6:01 PM, Isiah Meadows <isiahmead...@gmail.com>
wrote:

> C# isn't the only OO language to have references. PHP has them too,
> although the awkwardness isn't the references themselves as much as
> how the language integrates with them. OCaml also has reified
> references as separate from their mutable record properties.
>
> Note that C#'s "out" parameters aren't the same as what's being
> proposed here. Ron's proposal shares more in common with Rust's `foo:
> &mut Foo` parameters and C/C++'s `&foo` (address-of) operator than
> C#'s `out` parameters, since the proposal doesn't restrict their use
> to just parameters, and it doesn't just treat them as alternate return
> targets. C# has those just for C interop and little else, while Rust
> and OCaml have them for general use. If we're going to have
> general-use references, let's not mimic C#'s very awkward mess when we
> do it.
>
> (JS is a much lower level language than it looks. It abstracts less
> than most other common dynamic languages.)
>
>
I didn't mean to stress 'out'.  'ref' was really the only thing I meant for
a take-away.

other than in parameters, I don't see a use...
I went back to the top and re-read with these new colored glasses...

var:prt is terrible; that would be a printer...or maybe part  :)  var:ptr;
and since it's not a pointer, maybe ref instead?


what if the property is a  setter/getter reference when getting a set/get
property.

var x = {
  name : 'foo',
  get Name() { return name }
  set Name() { this.name = name };
}

var:ref getterRef = x.Name  // retain both set and get?

var:ref xName = x.name;

(then changing either xName or x.name (or x.Name) to a new value



> -----
>
> Isiah Meadows
> m...@isiahmeadows.com
>
> Looking for web consulting? Or a new website?
> Send me an email and we can get started.
> www.isiahmeadows.com
>
>
> On Mon, Mar 19, 2018 at 8:37 PM, J Decker <d3c...@gmail.com> wrote:
> > Ahh parameters by reference yes have wished for that...
> >
> > ref is C#-ism to me... which also maybe 'out' which really isn't
> different
> > in JS.... in C# it enforces that the value is set in the function
> receiving
> > an out 'must give value to parameter'.
> >
> >
> > On Mon, Mar 19, 2018 at 5:28 PM, Isiah Meadows <isiahmead...@gmail.com>
> > wrote:
> >>
> >> This is basically what I was proposing, ironically enough. There's a
> >> few small differences, but the only one that substantially varied from
> >> mine I filed an issue in your repo against. (I almost went for
> >> `value`.)
> >>
> >> BTW, yours looks a *lot* like OCaml's `ref 'a` type, which is just
> >> sugar for `{mutable contents : 'a}`. The only difference is that OCaml
> >> doesn't allow you to take a reference to a mutable property, while
> >> yours does.
> >> -----
> >>
> >> Isiah Meadows
> >> m...@isiahmeadows.com
> >>
> >> Looking for web consulting? Or a new website?
> >> Send me an email and we can get started.
> >> www.isiahmeadows.com
> >>
> >>
> >> On Mon, Mar 19, 2018 at 7:57 PM, Ron Buckton <ron.buck...@microsoft.com
> >
> >> wrote:
> >> >> -----Original Message-----
> >> >> From: es-discuss <es-discuss-boun...@mozilla.org> On Behalf Of Isiah
> >> >> Meadows
> >> >> Sent: Monday, March 19, 2018 3:21 PM
> >> >> To: Michael J. Ryan <track...@gmail.com>
> >> >> Cc: es-discuss <es-discuss@mozilla.org>
> >> >> Subject: Re: Pointers
> >> >>
> >> >> And even if we *could* get pointers into JS, I'd *strongly* not want
> it
> >> >> to be
> >> >> like what's proposed here. Instead, I'd prefer an object
> encapsulating
> >> >> a
> >> >> reference to a variable, something like this (although engines could
> >> >> avoid the
> >> >> ceremony of closures here):
> >> >>
> >> >> ```js
> >> >> let foo = 1;
> >> >>
> >> >> func(ref foo, bar)
> >> >> // Equivalent to:
> >> >> func({deref: () => foo, set: v => foo = v}, bar)
> >> >>
> >> >> function func(ref foo, bar) {
> >> >>     foo += 2
> >> >> }
> >> >>
> >> >> // Equivalent to:
> >> >> function func(foo) {
> >> >>     foo.set(foo.deref() + 2)
> >> >> }
> >> >> ```
> >> >
> >> > I put together a strawman for this last year at
> >> > https://github.com/rbuckton/proposal-refs, but I haven't had much
> time to
> >> > work on it.
> >> >
> >> > Ron
> >> _______________________________________________
> >> es-discuss mailing list
> >> es-discuss@mozilla.org
> >> https://mail.mozilla.org/listinfo/es-discuss
> >
> >
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to