Ticket #162 (closed defect: worksforme)

Opened 1 year ago

Last modified 1 year ago

No longer need {*}

Reported by: cormac Assigned to: anonymous
Type: defect Priority: major
Milestone: M2 Component: Proposals
Version: 4 Keywords:
Cc: dherman@ccs.neu.edu, brendan@mozilla.org, lth@acm.org, jodyer@adobe.com, graydon@mozilla.com

Description (last modified by cormac) (diff)

With like and wrap, it appears {*} is mostly redundant. Its primary purpose was as an implicit annotation on untyped objects, but in that role it now appears equivalent to {}.

Consider:

let x1 = {f:3} : {*}
let x2 = {f:3} : {}
function g    (arg:      {f:int}) ...
function glike(arg: like {f:int}) ...
function gwrap(arg: wrap {f:int}) ...

Both g(x1) and g(x2) fail. All of glike(x1), glike(x2), gwrap(x1), and gwrap(x2) succeed. (At least, I argue they should, though the glike(x2) situation has not been explicitly discussed yet.)

Note that {*} could still be useful as an explicit type annotation, as a function return type, say, but that might not be enough to justify the added complexity.

Attachments

Change History

Changed 1 year ago by cormac

  • description changed from With like and wrap, it appears {*} is mostly redundant. Its primary purpose was as an implicit annotation on untyped objects, but in that role it now appears equivalent to {}. Consider: {{{ let x1 = {f:int} : {*} let x2 = {f:int} : {} function g (arg: {f:int}) ... function glike(arg: like {f:int}) ... function gwrap(arg: wrap {f:int}) ... }}} Both g(x1) and g(x2) fail. All of glike(x1), glike(x2), gwrap(x1), and gwrap(x2) succeed. (At least, I argue they should, though the glike(x2) situation has not been explicitly discussed yet.) Note that {*} could still be useful as an explicit type annotation, as a function return type, say, but that might not be enough to justify the added complexity. to With like and wrap, it appears {*} is mostly redundant. Its primary purpose was as an implicit annotation on untyped objects, but in that role it now appears equivalent to {}. Consider: {{{ let x1 = {f:3} : {*} let x2 = {f:3} : {} function g (arg: {f:int}) ... function glike(arg: like {f:int}) ... function gwrap(arg: wrap {f:int}) ... }}} Both g(x1) and g(x2) fail. All of glike(x1), glike(x2), gwrap(x1), and gwrap(x2) succeed. (At least, I argue they should, though the glike(x2) situation has not been explicitly discussed yet.) Note that {*} could still be useful as an explicit type annotation, as a function return type, say, but that might not be enough to justify the added complexity.

Changed 1 year ago by lth

  • status changed from new to closed
  • resolution set to worksforme

Redundant.

Note: See TracTickets for help on using tickets.