Skip to content

Why were tag functions chosen for the API? #52

@kee-oth

Description

@kee-oth

TypL looks extremely interesting! Thank you for putting so much work into it already!

I have kind of a surface level question: why were tag functions chosen for the API? I'm sure there are good reasons but from the outside-in perspective, it seems that normal function calls would be a little more ergonomic since there's a good bit less syntax:

Using tag functions:

function isEven(v = number) {
   return bool`${ v % 2 == 0 }`;
}

var x = number`42`;
var kind = bool`${ isEven(x) }`;

vs

Using "regular" functions:

function isEven(v = number) {
   return bool( v % 2 == 0);
}

var x = number(42);
var kind = bool( isEven(x) );

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions