io.baklan at gmail.com (2017-01-03T13:27:42.047Z)
For me ``.?.`` looks more strict. With variations: ``a.?.b.?.c``,
``a.?(args)``, ``a.?[key]``.
Since I would rather look on it like on something similar to [C# extension
method](https://msdn.microsoft.com/en-us//library/bb383977.aspx) (or [Scala
implicit method](
http://docs.scala-lang.org/overviews/core/implicit-classes.html)), and then
in its "full/extended form" it can be
```js
a.$selfOrNullObj().b.$selfOrNullObj().c
```
Where ``.$selfOrNullObj().`` exactly corresponds to ``.?.`` (or in other
words ``.?.`` might be shortcut for ``.$selfOrNullObj().``)
And in terms of [extension method](
https://msdn.microsoft.com/en-us//library/bb383977.aspx) this-argument not
required to be not-null (it is valid case when null passed in place of
this-argument into that static method which is extension method for some
other class).
Then in this case (inspired by that approach) it can be approximately
declared like:
```js
obj.?
```
<==>
```js
obj.$selfOrNullObj()
```
<==>
```js
(obj != null ? obj : {_proto_:null} )
// or (obj != null ? obj : ()=>{}) to be compatible with ``a.?(args)``
```
Then it also could be proposed some variation with fallback to particular
default, like
```js
obj.$selfOrDefault(defObj)
```
<==>
```js
obj.??(defObj)
```
<==>
```js
(obj != null ? obj : defObj )
```
Combining with ``Nil`` approach (some null object which semantically the
same as null, but returns itself for any operation - ``.``, ``[]``, ``()``
; can be easily implemented as ``Proxy`` object for ``()=>{}``), we can
achieve some sort of transitiveness
```js
a.??(nil).b.c.d.??(null)
```
But in general it fails if for example ``a.b != null`` but ``a.b.c ==
null``, and in this case this construct should work in more advanced way -
like, default value should be used not only for that particular
``.??(Nil).`` operation, but for all consequent ``.`` operations too, until
that default value will not be reset back to ``null`` by trailing
``.??(null)`` operation (which also should replace ``nil`` with ``null``).io.baklan at gmail.com (2017-01-03T13:25:35.257Z)
For me ``.?.`` looks more strict. With variations: ``a.?.b.?.c``,
``a.?(args)``, ``a.?[key]``.
Since I would rather look on it like on something similar to [C# extension
method](https://msdn.microsoft.com/en-us//library/bb383977.aspx) (or [Scala
implicit method](
http://docs.scala-lang.org/overviews/core/implicit-classes.html)), and then
in its "full/extended form" it can be
```js
a.$selfOrNullObj().b.$selfOrNullObj().c
```
Where ``.$selfOrNullObj().`` exactly corresponds to ``.?.`` (or in other
words ``.?.`` might be shortcut for ``.$selfOrNullObj().``)
And in terms of [extension method](
https://msdn.microsoft.com/en-us//library/bb383977.aspx) this-argument not
required to be not-null (it is valid case when null passed in place of
this-argument into that static method which is extension method for some
other class).
Then in this case (inspired by that approach) it can be approximately
declared like:
```js
obj.?
```
<==>
```js
obj.$selfOrNullObj()
```
<==>
```js
(obj != null ? obj : {_proto_:null} )
// or (obj != null ? obj : ()=>{}) to be compatible with ``a.?(args)``
```
Then it also could be proposed some variation with fallback to particular
default, like
```js
obj.$selfOrDefault(defObj)
```
<==>
```js
obj.??(defObj)
```
<==>
```js
(obj != null ? obj : defObj )
```
Combining with ``Nil`` approach (some null object which semantically the
same as null, but returns itself for any operation - ``.``, ``[]``, ``()``
; can be easily implemented as ``Proxy`` object for ``()=>{}``), we can
achieve some sort of transitiveness
```js
a.??(Nil).b.c.d.??(null)
```
But in general it fails if for example ``a.b != null`` but ``a.b.c ==
null``, and in this case this construct should work in more advanced way -
like, default value should be used not only for that particular
``.??(Nil).`` operation, but for all consequent ``.`` operations too, until
that default value will not be reset back to ``null`` by trailing
``.??(null)`` operation (which also should replace Nil with null).
For me ``.?.`` looks more strict. With variations: ``a.?.b.?.c``, ``a.?(args)``, ``a.?[key]``. Since I would rather look on it like on something similar to [C# extension method](https://msdn.microsoft.com/en-us//library/bb383977.aspx) (or [Scala implicit method]( http://docs.scala-lang.org/overviews/core/implicit-classes.html)), and then in its "full/extended form" it can be ```js a.$selfOrNullObj().b.$selfOrNullObj().c ``` Where ``.$selfOrNullObj().`` exactly corresponds to ``.?.`` (or in other words ``.?.`` might be shortcut for ``.$selfOrNullObj().``) And in terms of [extension method]( https://msdn.microsoft.com/en-us//library/bb383977.aspx) this-argument not required to be not-null (it is valid case when null passed in place of this-argument into that static method which is extension method for some other class). Then in this case (inspired by that approach) it can be approximately declared like: ```js obj.? ``` <==> ```js obj.$selfOrNullObj() ``` <==> ```js (obj != null ? obj : {_proto_:null} ) // or (obj != null ? obj : ()=>{}) to be compatible with ``a.?(args)`` ``` Then it also could be proposed some variation with fallback to particular default, like ```js obj.$selfOrDefault(defObj) ``` <==> ```js obj.??(defObj) ``` <==> ```js (obj != null ? obj : defObj ) ``` Combining with ``Nil`` approach (some null object which semantically the same as null, but returns itself for any operation - ``.``, ``[]``, ``()`` ; can be easily implemented as ``Proxy`` object for ``()=>{}``), we can achieve some sort of transitiveness ```js a.??(Nil).b.c.d.??(null) ``` But in general it fails if for example ``a.b != null`` but ``a.b.c == null``, and in this case this construct should work in more advanced way - like, default value should be used not only for that particular ``.??(Nil).`` operation, but for all consequent ``.`` operations too, until that default value will not be reset back to ``null`` by trailing ``.??(null)`` operation (which also should replace Nil with null). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170103/01778d67/attachment.html>