Native Assertions

Michael Haufe tno at thenewobjective.com
Mon Jan 14 19:04:11 UTC 2019


If the intent of assert is only about sanity checks, then this would not be
unreasonable. C# has done similar <
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debug.assert?view=netframework-4.7.2
>.

If this is treated as a foot in the door for Code Contracts, then extending
debugger is inappropriate as the intentions are different.

The latter subsumes the former, but is probably a bridge too far for
ECMAScript at this stage. I would practically look for:

import {assert} from ''std:contracts"

along with comparable behavior to: <
https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts
>

/Michael

On Mon, Jan 14, 2019 at 6:53 AM Michał Wadas <michalwadas at gmail.com> wrote:

> How about extending debugger statement?
>
> Eg. debugger.assert.
>
>
>
> On Mon, 14 Jan 2019, 12:39 Michael Haufe <tno at thenewobjective.com wrote:
>
>> console.assert is not standardized at this point, nor is it part of the
>> language. Additionally, the semantics are inappropriate for the required
>> use cases.
>>
>> To requote the relevant part from the linked thread:
>>
>> 1. AssertionError <: Error
>> 2. assert(x === 12); // throws an AssertionError with a default error
>> message
>> 3. assert(x === 12, "twelve, supposedly") // throws an AssertionError
>> with the given error message
>>
>> console.assert does not throw and its intent is not the same. The assert
>> I'm referring to is related to Code Contracts. Therefore your reference is
>> seemingly orthogonal.
>>
>> /Michael
>>
>> On Sun, Jan 13, 2019, 12:49 Cyril Auburtin <cyril.auburtin at gmail.com
>> wrote:
>>
>>> There's `console.assert`
>>>
>>> also check
>>> https://github.com/michaelficarra/proposal-first-class-protocols/issues/27#issuecomment-386975099
>>>
>>>
>>> On Sun, Dec 16, 2018 at 10:01 PM Michael Haufe <tno at thenewobjective.com>
>>> wrote:
>>>
>>>> Seven years ago there was discussion around standardizing "assert". Has
>>>> there been any movement on this since then?
>>>>
>>>> https://esdiscuss.org/topic/native-assertion-module
>>>>
>>>>
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190114/f86b5dde/attachment.html>


More information about the es-discuss mailing list