Re: Status/Thoughts on Guards?

2014-08-30 Thread John Lenz
Not exactly the same but the Closure Compiler has a "runtime type check" mode that inject type checks. If you write jsdoc type annotations already this can be an low resistance path but its usefulness depends on the accuracy of those annotations. On Aug 21, 2014 6:54 AM, "Curtis Steckel" wrote:

Re: Status/Thoughts on Guards?

2014-08-21 Thread Curtis Steckel
These are all great examples and resources. Thanks everyone. On Thursday, August 21, 2014, Charles Pick wrote: > Just to throw another example out there, here's a Design by Contract > library which squeezes itself within existing ES syntax - > https://github.com/codemix/contractual > ___

Re: Re: Status/Thoughts on Guards?

2014-08-21 Thread Charles Pick
Just to throw another example out there, here's a Design by Contract library which squeezes itself within existing ES syntax - https://github.com/codemix/contractual ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-d

Re: Status/Thoughts on Guards?

2014-08-19 Thread Brendan Eich
Jonathan Barronville wrote: +1 for https://research.microsoft.com/pubs/224900/safets.pdf ... some really good research. Yes, it's good. As Mark said, though, it's more likely we'll get a fight than anything productive from such a conversation, which is quite unfortunate :( . Best thing alre

Re: Status/Thoughts on Guards?

2014-08-19 Thread Jonathan Barronville
sort, whether starting from guards or from either of the approaches > above. > > From discussions at TC39, it is clear that any such proposal would be a > long fight. I don't know that anyone is willing to invest the time needed > to lead that fight. I know I'm not -- it is

Re: Status/Thoughts on Guards?

2014-08-19 Thread Mark S. Miller
See also http://disnetdev.com/blog/2011/08/23/Contracts.coffee-Contracts-For-JavaScript-and-CoffeeScript/ and http://research.microsoft.com/apps/pubs/default.aspx?id=224900 I am a fan of making it notationally easier to inject runtime validation of some sort, whether starting from guards or from

Status/Thoughts on Guards?

2014-08-19 Thread Curtis Steckel
hp?id=strawman:guards. **I'm curious what TC39 and the es-discuss' current thoughts and attitudes towards guards is at the moment.** They seem to come up every once in a while in TC39 notes, but usually only through a tangential mention followed by a mix of "that would eliminate the p

Re: Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
> Aren't you assuming a certain kind of guards, namely converting rather than > throwing? There's no way to future-proof without more agreement on what the > default meaning of x :: Number would be, and (AFAIK) we don't have consensus > yet. Yes, in the future of

Re: Preparing for type guards

2011-12-29 Thread Brendan Eich
Aren't you assuming a certain kind of guards, namely converting rather than throwing? There's no way to future-proof without more agreement on what the default meaning of x :: Number would be, and (AFAIK) we don't have consensus yet. Anyway, no one is going to start wri

Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
Once we have type guards, I would expect the JavaScript programming style to slightly change. Currently, number-valued arguments are implemented like this: function foo(x) { x = Number(x); } With guards, you would use: function foo(x :: Number) { } It might make sense

Re: JsDoc based type guards

2011-10-14 Thread James Burke
On Fri, Oct 14, 2011 at 5:23 AM, Peter Dekkers wrote: > 1. JsDoc becomes a standard part of Language. This has to be a good > thing  even without using it is as basis for stronger typing: a > uniform way of documenting code. > 2. No new language constructs are required. > 3. Relatively simple to i

Re: JsDoc based type guards

2011-10-14 Thread Quildreen Motta
2011/10/14 Peter Dekkers > > I checked the strawman and it looks nice. However the introduction of > something like "::" would surely not run on older VM's that don't > understand that construct. Is that not a perceived problem more in > general: adding a nice new language constructs that people

Re: JsDoc based type guards

2011-10-14 Thread John J Barton
On Fri, Oct 14, 2011 at 7:44 AM, Peter Dekkers wrote: > Focus seems to be much on JsDoc, while I just meant it as an example. > Didn't realize the sensitive nature of bringing up that documentation > convention, sorry for that. > > I checked the strawman and it looks nice. However the introducti

Re: JsDoc based type guards

2011-10-14 Thread Peter Dekkers
the former -- contracts >>> >>> Contracts are not necessarily static. In many languages they are dynamic. >>> The disnetdev.com/contracts.coffee/ work is a case in point. >>> >> >> That's true. We've discussed contracts.coffee in the guar

Re: JsDoc based type guards

2011-10-14 Thread Jake Verbaten
is not a statically typed language, it's an overtly dynamic >> language with prototypical OO. Using it as the former -- contracts >> >> Contracts are not necessarily static. In many languages they are dynamic. >> The disnetdev.com/contracts.coffee/ work is a case in point. &

Re: JsDoc based type guards

2011-10-14 Thread Quildreen Motta
2011/10/14 Jake Verbaten > > > On Fri, Oct 14, 2011 at 2:44 PM, Peter Dekkers wrote: > > I think the entire proposal based on auto generating gaurds from > documentation is not that useful. It forces you into a type of > documentation. I want to choose my documentation, I dont want these choic

Re: JsDoc based type guards

2011-10-14 Thread Quildreen Motta
pical OO. Using it as the former -- contracts > > Contracts are not necessarily static. In many languages they are dynamic. > The disnetdev.com/contracts.coffee/ work is a case in point. > > That's true. We've discussed contracts.coffee in the guards thread before too -- whose syntax

Re: JsDoc based type guards

2011-10-14 Thread Jake Verbaten
On Fri, Oct 14, 2011 at 2:44 PM, Peter Dekkers wrote: > True of course that JS is a dynamic language by nature and it is not > my suggestion/intention to make it more typed. I strongly believe the > prototype part of JS is one of its main selling points. > > However a function expects certain typ

Re: JsDoc based type guards

2011-10-14 Thread Brendan Eich
se -- predicates. They're evaluated at runtime. The guards strawman is intentionally also runtime-evaluated. In it, a declaration such as let x :: G = v; cannot be evaluated statically in general. G is an expression in the language evaluated in the same regime, and in the order specif

Re: JsDoc based type guards

2011-10-14 Thread Peter Dekkers
True of course that JS is a dynamic language by nature and it is not my suggestion/intention to make it more typed. I strongly believe the prototype part of JS is one of its main selling points. However a function expects certain type(s) of input parameters in order to work properly. My suggestion

Re: JsDoc based type guards

2011-10-14 Thread Quildreen Motta
2011/10/14 Peter Dekkers > Some of the advantages I could see: > > 1. JsDoc becomes a standard part of Language. This has to be a good > thing even without using it is as basis for stronger typing: a > uniform way of documenting code. > I fail to see why "One True Way" for everything would be a

Re: JsDoc based type guards

2011-10-14 Thread Peter Dekkers
, >> >> I'm new on this list, so please forgive me if this subject has already >> been discussed in the past (I could't find a reference to that, but >> perhaps looked in the wrong places) . >> >> I saw that some form of type guards are on the ag

Re: JsDoc based type guards

2011-10-14 Thread Jake Verbaten
Peter Dekkers wrote: > All, > > I'm new on this list, so please forgive me if this subject has already > been discussed in the past (I could't find a reference to that, but > perhaps looked in the wrong places) . > > I saw that some form of type guards are on the agenda

JsDoc based type guards

2011-10-14 Thread Peter Dekkers
All, I'm new on this list, so please forgive me if this subject has already been discussed in the past (I could't find a reference to that, but perhaps looked in the wrong places) . I saw that some form of type guards are on the agenda and was wondering if anyone looked at using JsDoc

Re: Minimal type guards?

2011-10-13 Thread Quildreen Motta
2011/10/13 Brendan Eich > On Oct 13, 2011, at 3:29 PM, Kris Kowal wrote: > > > Your proposal resembles Waldemar’s guards and trademarks. > > > > http://wiki.ecmascript.org/doku.php?id=strawman:trademarks > > http://wiki.ecmascript.org/doku.php?id=strawman:gua

Re: Minimal type guards?

2011-10-13 Thread Brendan Eich
To say a bit more, since we have live strawman proposals for Harmony, these are on the agenda. It wouldn't be kosher for an implementor to use :: for something quite different (let's ignore E4X, shall we? ;-), or to add "guards" under different syntax, without first at least

Re: Minimal type guards?

2011-10-13 Thread Brendan Eich
On Oct 13, 2011, at 3:29 PM, Kris Kowal wrote: > Your proposal resembles Waldemar’s guards and trademarks. > > http://wiki.ecmascript.org/doku.php?id=strawman:trademarks > http://wiki.ecmascript.org/doku.php?id=strawman:guards > > You might consider building on these t

Re: Minimal type guards?

2011-10-13 Thread Kris Kowal
lationships --, I'd rather go with a predicate functions, but then that's > even more expensive. Quildreen, Your proposal resembles Waldemar’s guards and trademarks. http://wiki.ecmascript.org/doku.php?id=strawman:trademarks http://wiki.ecmascript.org/doku.php?id=strawman:guar

Re: Minimal type guards?

2011-10-13 Thread Quildreen Motta
hmayer > Similar to the minimal classes idea: Is there a sweet spot between nothing > at all and full-blown type guards that would have a chance to make it into > ES.next? > > The minimal useful feature set that I can think of: > 1. instanceof checks: is an argument an instance of

Minimal type guards?

2011-10-13 Thread Axel Rauschmayer
Similar to the minimal classes idea: Is there a sweet spot between nothing at all and full-blown type guards that would have a chance to make it into ES.next? The minimal useful feature set that I can think of: 1. instanceof checks: is an argument an instance of a given type? 2. property name

Re: Guards

2011-05-27 Thread David Herman
ument that is a string >>>> and returns an integer. Perhaps MyType has to be an object with two >>>> function properties named alpha and beta. >>> >>> Exactly! Some in TC39 want to research contract systems for JS. >> >> This is an altern

Re: Guards

2011-05-27 Thread Brendan Eich
MyType is a >>> can only be a function that takes a single argument that is a string >>> and returns an integer. Perhaps MyType has to be an object with two >>> function properties named alpha and beta. >> >> Exactly! Some in TC39 want to research contract sys

Re: Guards

2011-05-27 Thread John Tamplin
On Fri, May 27, 2011 at 4:43 PM, Peter Michaux wrote: > Yes but I was thinking of the use of guards as a debugging/development > tool. During development you can verify that foo is never called with > bad values. Then during production, those checks do not need to be > performed. By

Re: Guards

2011-05-27 Thread Peter Michaux
>> Why? > > Because foo(7) produces a TypeError in one, and |undefined| in the > other (assuming that MyType isn't Number). Yes but I was thinking of the use of guards as a debugging/development tool. During development you can verify that foo is never called w

Re: Guards

2011-05-27 Thread Sam Tobin-Hochstadt
On Fri, May 27, 2011 at 4:03 PM, Peter Michaux wrote: > On Fri, May 27, 2011 at 12:55 PM, Sam Tobin-Hochstadt > wrote: >> On Fri, May 27, 2011 at 1:59 PM, Peter Michaux >> wrote: >>> >>> A minifier could, couldn't it? >>> >>> function foo(a::MyType) {} >>> >>> would be minified to >>> >>> func

Re: Guards

2011-05-27 Thread Peter Michaux
On Fri, May 27, 2011 at 12:55 PM, Sam Tobin-Hochstadt wrote: > On Fri, May 27, 2011 at 1:59 PM, Peter Michaux wrote: >> >> A minifier could, couldn't it? >> >> function foo(a::MyType) {} >> >> would be minified to >> >> function foo(a) {} > > These are not the same function at all. Why? Peter _

Re: Guards

2011-05-27 Thread Sam Tobin-Hochstadt
On Fri, May 27, 2011 at 1:59 PM, Peter Michaux wrote: > > A minifier could, couldn't it? > > function foo(a::MyType) {} > > would be minified to > > function foo(a) {} These are not the same function at all. -- sam th sa...@ccs.neu.edu ___ es-discuss m

Re: Guards

2011-05-27 Thread Peter Michaux
On Fri, May 27, 2011 at 1:44 AM, Brendan Eich wrote: > On May 26, 2011, at 9:36 PM, Peter Michaux wrote: > > > I'm looking at the strawman for guards. > > > > http://wiki.ecmascript.org/doku.php?id=strawman:guards > > > > I don't quite see how th

Re: Guards

2011-05-27 Thread Brendan Eich
On May 26, 2011, at 9:36 PM, Peter Michaux wrote: > I'm looking at the strawman for guards. > > http://wiki.ecmascript.org/doku.php?id=strawman:guards > > I don't quite see how they are created. > > I understand this part about how they would be used > >

Guards

2011-05-26 Thread Peter Michaux
> Cormac's student Tim will work with > DaveH to prototype this this summer. Not advanced to Harmony, pending > more user experience. How will more user experience be generated? Through a compiler to ES5? -- The idea of guards in general seems extremely useful and could potential

Proposal: Guards and Trademarks

2011-05-06 Thread Waldemar Horwat
I placed guards and trademarks on the agenda for this month's meeting. They're intentionally a relatively bare-bones and secure mechanism: http://wiki.ecmascript.org/doku.php?id=strawman:guards http://wiki.ecmascript.org/doku.php?id=strawman:trademarks These partially rely on a mec

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread P T Withington
On 2010-11-22, at 14:33, Brendan Eich wrote: > Is losing the braces really worth the added complexity? Perhaps not. Braces are surely as good a way to denote keyword args as any other flag. It occurred to me that there is no equivalent of object literals in the languages I know that have keyw

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Brendan Eich
On Nov 22, 2010, at 11:12 AM, Brendan Eich wrote: >> Would keyword arguments ever be added to JS? Any chance that would >> influence the choices made here? > > Imponderable unless we reserve : in call expressions such as > > foo(arg1: val1, arg3: val3); > > to mean named formal parameter asso

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Brendan Eich
On Nov 22, 2010, at 10:58 AM, P T Withington wrote: > On 2010-11-22, at 13:13, Brendan Eich wrote: > >> That, plus the relative rarity of annotated initialisers (in my best guess >> -- we can argue about this or try to estimate by adding guards to existing >> code)

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread P T Withington
On 2010-11-22, at 13:13, Brendan Eich wrote: > That, plus the relative rarity of annotated initialisers (in my best guess -- > we can argue about this or try to estimate by adding guards to existing > code), make me still favor (2). The idea of guards as "adjectives" (ala

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Brendan Eich
of saying, notation is user interface. And how! But doubling a colon is not better interface. Especially when that double-tax hits all declarations, not just object initialisers. Let's see if I can write down some alternatives and list trade-offs: 0. let typedObj = { foo : 33 } : { f

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Mark Miller
On Mon, Nov 22, 2010 at 12:37 AM, Peter van der Zee wrote: > > Can't the guards proposal be applied to function parameters as well? Or am > I stepping on land mines there? :) > Yes. Please look at the guards strawman. It's in there. --

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Mark S. Miller
On Mon, Nov 22, 2010 at 1:09 AM, Brendan Eich wrote: > [...] Before reaching in a reactive way for @, let's slow down and consider > what got us here: over-eager bikeshedding of : instead of "in" [...] > That's not what got me here. For me the issue is uniformity of guard syntax across all conte

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Brendan Eich
; colons are required per property initialiser. There's no need for :: or > anything else except to avoid a confusing re-use of colon. Which is an issue, > but :: doesn't exactly address it! > > > As you noted yourself in the other thread, if iterators take on the syntax

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Peter van der Zee
need for :: or > anything else except to avoid a confusing re-use of colon. Which is an > issue, but :: doesn't exactly address it! > > As you noted yourself in the other thread, if iterators take on the syntax of `for (var x : y : z)`, the single colon for guards would introduce am

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Brendan Eich
> Actually, for object literal I'd go for an equal sign (=), but that obviously > won't fix var declarations where the colon is fine. We're not changing object initialiser syntax. > Can't the guards proposal be applied to function parameters as well? Or am I >

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-22 Thread Peter van der Zee
# or @ ... Actually, for object literal I'd go for an equal sign (=), but that obviously won't fix var declarations where the colon is fine. Can't the guards proposal be applied to function parameters as well? Or am I stepping on land mines there? :) It seems like the same logic coul

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Brendan Eich
On Nov 21, 2010, at 7:52 PM, Mark S. Miller wrote: > On Sun, Nov 21, 2010 at 7:48 PM, Brendan Eich wrote: >> The reason I chose "::" over ":" is not for a love of "::". Alternative >> suggestions appreciated! However, I avoided ":" so that we could guard >> properties within object literals >>

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Mark S. Miller
IMHO. >> > > > Since this is a purely bikeshedding issue, I don't need to be too > embarrassed by posting the first color. How about "@"? > If we think of guards as annotations, then this kinda sorta has a precedent in Java annotations (if you squint hard enou

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Mark S. Miller
On Sun, Nov 21, 2010 at 7:48 PM, Brendan Eich wrote: > :: is strictly less pleasant, and really kind of "taken" due to the > precedents I cited. The "less pleasant" point is the big one IMHO. > Since this is a purely bikeshedding issue, I don't need to be too embarrassed by posting the first co

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Mark S. Miller
new for syntax is confusingly similar to >> long-standing future-proofing intentions around runtime type annotations >> (aka guards or contracts). >> >> (BTW, I don't think :: is a good type annotation or guard punctuator, btw >> -- it's the C++ namespace qual

Re: Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Brendan Eich
tentions around runtime type annotations (aka > guards or contracts). > > (BTW, I don't think :: is a good type annotation or guard punctuator, btw -- > it's the C++ namespace qualification operator, also specified for namespacing > by ECMA-357 (E4X) and used that way i

Guards are now ready for discussion (was: Nov 18 notes)

2010-11-21 Thread Mark S. Miller
On Sun, Nov 21, 2010 at 7:05 PM, Brendan Eich wrote: > On Nov 18, 2010, at 4:08 PM, Waldemar Horwat wrote: > [...] > Worse, the use of colon in this new for syntax is confusingly similar to > long-standing future-proofing intentions around runtime type annotations > (aka guar