carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

Proposal: ES-like 'import.meta'

Open hydroper opened this issue 3 years ago • 0 comments
trafficstars

In ECMAScript, the import.meta expression (meta is a context keyword) returns {url}, where url indicates the URL of the current script. Carbon scripts could have such ability. For example:

file:///C:/Users/anonymous/Documents/foo.carbon

var {url} = import.meta;
Assert(url == 'file:///C:/Users/anonymous/Documents/foo.carbon');

This would be useful for a NodeJS-like platform that uses Carbon. NodeJS also has __filename, but seems unfriendly.

hydroper avatar Aug 21 '22 20:08 hydroper