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

Issue 10694089: Guard the use of write in the implementation of print. (Closed)

Created:
8 years, 5 months ago by kasperl
Modified:
8 years, 5 months ago
Reviewers:
Emily Fortuna
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Guard the use of write in the implementation of print. R=efortuna@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=9417

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -9 lines) Patch
M lib/compiler/implementation/lib/js_helper.dart View 1 chunk +14 lines, -9 lines 4 comments Download

Messages

Total messages: 3 (0 generated)
kasperl
8 years, 5 months ago (2012-07-05 11:38:52 UTC) #1
Emily Fortuna
lgtm with comments https://chromiumcodereview.appspot.com/10694089/diff/1/lib/compiler/implementation/lib/js_helper.dart File lib/compiler/implementation/lib/js_helper.dart (right): https://chromiumcodereview.appspot.com/10694089/diff/1/lib/compiler/implementation/lib/js_helper.dart#newcode373 lib/compiler/implementation/lib/js_helper.dart:373: bool hasDartPrint = JS('bool', @'typeof dartPrint ...
8 years, 5 months ago (2012-07-05 11:46:42 UTC) #2
kasperl
8 years, 5 months ago (2012-07-05 11:49:03 UTC) #3
Thanks, Emily!

https://chromiumcodereview.appspot.com/10694089/diff/1/lib/compiler/implement...
File lib/compiler/implementation/lib/js_helper.dart (right):

https://chromiumcodereview.appspot.com/10694089/diff/1/lib/compiler/implement...
lib/compiler/implementation/lib/js_helper.dart:373: bool hasDartPrint =
JS('bool', @'typeof dartPrint == "function"');
On 2012/07/05 11:46:42, Emily Fortuna wrote:
> nit: the style guide suggests having leaving variables untyped if they're
local
> and it's obvious, but if you prefer it this way, I can accept that too.

Done.

https://chromiumcodereview.appspot.com/10694089/diff/1/lib/compiler/implement...
lib/compiler/implementation/lib/js_helper.dart:379: bool hasConsole = JS('bool',
@'typeof console == "object"');
On 2012/07/05 11:46:42, Emily Fortuna wrote:
> nit: personally I'd write this as 
> if (hasDartPrint) {
>        JS('void', @'dartPrint(#)', string);
> } else if(JS('bool', @'typeof console == "object"')) {
>       JS('void', @'console.log(#)', string);
> } else if (JS('bool', @'typeof write == "function"')) {
> etc
> 
> just to make the control flow a little clearer, but this is fine, too if you
> prefer.

In this case, I think the JS expressions are a bit obscure so I prefer to be
able to "name" them. With the extra local variables the nesting gets a bit
annoying which is why I went for the variant with explicit returns.

Powered by Google App Engine
This is Rietveld 408576698