Skip to content

Instantly share code, notes, and snippets.

Problems With Using Parentheses for Type Argument Lists

Changes to the syntax of type parameters have been suggested multiple times by now. And while there may be a point to make about readability, function declarations using type parameters as described in the proposal will stay unambiguous. However, ambiguity arises when it comes to the proposed way of using type arguments, as call expressions may look the same, despite having different meanings depending on whether their arguments are types or values.

While it seems to be consensus in the community that using different brackets for type parameters and arguments by now, the following points have not been mentioned yet and further support the change.

Drawbacks when reading code

Assume we have a generic function that doubles an addable type:

var keyCodes = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAUSE: 19,
BREAK: 19,
CAPS_LOCK: 20,
@dddent
dddent / conf.js
Last active January 26, 2016 12:56
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['beispieltest.js'],
onPrepare: function() {
browser.manage().window().setSize(1600, 1000);
}
}
@dddent
dddent / apiVariante1.js
Last active January 18, 2016 10:56
API call varianten
mcDataService().then(function(apiObject) {
apiObject.template.get(2).then(function(data) {
// do stuff w/ data
},
function(err, res) {
console.log('error getting template.');
});
},
function (err) {
console.log('error recieving apiObject');
(function () {
var appName = 'MedCloudApp';
var controllerName = '[ControllerName]';
var requirements = ['[requirement1], [requirement2], [...]'];
var controller = function ([dependencies]) {
// controller code
};
@dddent
dddent / myhelper.js
Last active August 29, 2015 14:16
This is just a file that contains my MyHelper class, in which I add useful classes and function that I need to use often when working with js.
/* Myhelper */
var MyHelper = {}
MyHelper.getValueOfPixelString = function(string) {
if(string.indexOf("px") > -1) {
res = Number(string.replace("px",""));
if(res) return res;
else {
console.log('ERROR in MyHelper.getValueOfPixelString():'
+ ' replacing "px" in passed string "' + string + '" did not return a'