Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Issue 1324933002: Proposed spec for DEP for assert with messages.

Created:
5 years, 3 months ago by gbracha
Modified:
5 years ago
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Proposed spec for DEP for assert with messages. BUG=

Patch Set 1 #

Total comments: 15

Patch Set 2 : Allow expression for message in assert #

Total comments: 5

Patch Set 3 : Revise assert #

Total comments: 7

Patch Set 4 : Update version number #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+22 lines, -9 lines) Patch
M docs/language/dartLangSpec.tex View 1 2 3 4 chunks +22 lines, -9 lines 9 comments Download

Messages

Total messages: 34 (6 generated)
gbracha
Proposed assert spec changes, for those who prefer latex input to its output :-)
5 years, 3 months ago (2015-09-01 18:30:54 UTC) #2
Paul Berry
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6460 docs/language/dartLangSpec.tex:6460: assert `(' conditionalExpression (`,' stringLiteral)? `)' `{\escapegrammar ;}' Did ...
5 years, 3 months ago (2015-09-01 19:59:49 UTC) #3
sra1
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6472 docs/language/dartLangSpec.tex:6472: If the assertion failed and the assertion is of ...
5 years, 3 months ago (2015-09-01 22:46:47 UTC) #5
gbracha
So the constructor is specified in the DEP. The language spec uses it. If the ...
5 years, 3 months ago (2015-09-01 23:53:10 UTC) #6
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6460 docs/language/dartLangSpec.tex:6460: assert `(' conditionalExpression (`,' stringLiteral)? `)' `{\escapegrammar ;}' You ...
5 years, 3 months ago (2015-09-02 07:36:49 UTC) #8
sra1
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6471 docs/language/dartLangSpec.tex:6471: If the assertion failed, and the assertion is of ...
5 years, 3 months ago (2015-09-02 18:08:03 UTC) #9
gbracha
Changed stringLiteral to expression. Haven't changed anything else so far. https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6471 ...
5 years, 3 months ago (2015-09-02 19:58:23 UTC) #10
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6471 docs/language/dartLangSpec.tex:6471: If the assertion failed, and the assertion is of ...
5 years, 3 months ago (2015-09-03 05:22:08 UTC) #11
sra1
https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex#newcode6478 docs/language/dartLangSpec.tex:6478: The definition above implies that if $s$ does not ...
5 years, 3 months ago (2015-09-17 19:55:22 UTC) #12
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex#newcode6472 docs/language/dartLangSpec.tex:6472: If the assertion failed and the assertion is of ...
5 years, 3 months ago (2015-09-18 12:26:28 UTC) #13
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/1/docs/language/dartLangSpec.tex#newcode6472 docs/language/dartLangSpec.tex:6472: If the assertion failed and the assertion is of ...
5 years, 3 months ago (2015-09-22 08:41:58 UTC) #14
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/20001/docs/language/dartLangSpec.tex#newcode6478 docs/language/dartLangSpec.tex:6478: The definition above implies that if $s$ does not ...
5 years, 2 months ago (2015-10-15 09:14:48 UTC) #15
gbracha
So here is a revision in line with the discussion in the DEP committee. Let ...
5 years, 1 month ago (2015-11-04 00:36:05 UTC) #16
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex#newcode6472 docs/language/dartLangSpec.tex:6472: If the assertion failed, and the assertion is of ...
5 years, 1 month ago (2015-11-04 11:58:46 UTC) #17
Paul Berry
lgtm https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex#newcode6474 docs/language/dartLangSpec.tex:6474: If the assertion failed and the assertion is ...
5 years, 1 month ago (2015-11-04 16:48:17 UTC) #18
gbracha
https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/40001/docs/language/dartLangSpec.tex#newcode6472 docs/language/dartLangSpec.tex:6472: If the assertion failed, and the assertion is of ...
5 years, 1 month ago (2015-11-04 21:27:30 UTC) #19
Lasse Reichstein Nielsen
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years, 1 month ago (2015-11-05 16:22:26 UTC) #20
Brian Wilkerson
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years, 1 month ago (2015-11-05 17:04:37 UTC) #22
Bob Nystrom
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years, 1 month ago (2015-11-05 17:50:04 UTC) #24
gbracha
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years, 1 month ago (2015-11-05 19:25:01 UTC) #25
Paul Berry
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years, 1 month ago (2015-11-05 19:35:26 UTC) #26
Bob Nystrom
On 2015/11/05 19:35:26, Paul Berry wrote: > https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex > File docs/language/dartLangSpec.tex (right): > > https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 ...
5 years, 1 month ago (2015-11-05 21:10:51 UTC) #27
Lasse Reichstein Nielsen
On 2015/11/05 21:10:51, Bob Nystrom wrote: > I look at it like this: > > ...
5 years, 1 month ago (2015-11-09 11:59:40 UTC) #28
Lasse Reichstein Nielsen
On 2015/11/05 21:10:51, Bob Nystrom wrote: > I look at it like this: > > ...
5 years, 1 month ago (2015-11-09 11:59:41 UTC) #29
floitsch
I feel bad, advocating for yet another specification of this feature. https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): ...
5 years, 1 month ago (2015-11-18 21:16:37 UTC) #31
Lasse Reichstein Nielsen
On 2015/11/18 at 21:16:37, floitsch wrote: > Imho asserts should be simple: > if (!assert-condition) ...
5 years, 1 month ago (2015-11-20 10:51:58 UTC) #32
gbracha
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex File docs/language/dartLangSpec.tex (right): https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangSpec.tex#newcode6473 docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion is of ...
5 years ago (2015-11-24 20:26:04 UTC) #33
mit
5 years ago (2015-12-03 11:51:50 UTC) #34
On 2015/11/24 20:26:04, gbracha wrote:
>
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangS...
> File docs/language/dartLangSpec.tex (right):
> 
>
https://codereview.chromium.org/1324933002/diff/60001/docs/language/dartLangS...
> docs/language/dartLangSpec.tex:6473: If the assertion failed and the assertion
> is of the form \code{\ASSERT{}($e$, $s$);} then the expression $s$ is
evaluated
> to a value $o_s$. If evaluation of $s$ fails, an \cd{AssertionError} is
thrown.
> Otherwise, the \cd{toString()} method is invoked on $o_s$ resulting in a
string
> object $m$. If the invocation of \cd{toString()} throws an exception, an
> \cd{AssertionError} is thrown. Otherwise,
> On 2015/11/18 21:16:36, floitsch wrote:
> > Late to the party...
> > I'm not going to make this easier, but I think this is too complicated.
> > Imho asserts should be simple:
> > if (!assert-condition) throw new AssertionError(s);
> > 
> > Except that I don't want to force a specific assertion-error constructor.
> > Basically, I want the VM/dart2js to have the most flexibility in how it
> > constructs the assertion error.
> > It would be considered good practice to have `s` as `reason` field in the
> > AssertionError, but I don't think that needs to be specified in the language
> > spec.
> > 
> > I don't think that we should do a toString here. The AssertionError can do
> that
> > it its own 'toString' method. (most likely using a 'safeToString').
> > 
> > Something like:
> > ===
> > If the assertion failed and the assertion is of the form
\code{\ASSERT{}($e$,
> > $r$);} then the expression $r$ is evaluated to a value $o$. If the
evaluation
> of
> > $o$ succeeds (i.e. no exception), then an \cd{AssertionError} with $o$ as
> reason
> > is thrown.
> > 
> > \commentary{
> > The definition above implies that $r$ is not evaluated if the assertion
> > succeeded.
> > 
> > The definition above does not specify how the AssertionError is constructed.
> > This gives embedders the freedom to store more helpful information in the
> thrown
> > instance.
> > ===
> 
> So we are going around in circles. The original specification was given terms
of
> calling a constructor. It ensures consistent semantics and a minimum of
> implementation effort, since everything is done in terms of existing
mechanism. 
> After endless discussion, it boils down to exactly that except that you don't
> want to commit to having a constructor in the library.
> 
> As for toString, the whole purpose of it is to allow people to customize how
an
> object appears. They don't want some generic description generated by the
> system. 
> 
> Of course, it  is all a tempest in a teapot, because in reality s will be a
> string and it would be better to statically check that, but we've given up on
> that. I think we should leave it as is at this point and get on with our
lives.

What is the status here? We have a number of work items slated for 1.14 that are
waiting for the spec to be completed (see
https://github.com/dart-lang/sdk/issues/24213)

Powered by Google App Engine
This is Rietveld 408576698