New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support introspecting closures #560

Closed
xiaq opened this Issue Jan 9, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@xiaq
Member

xiaq commented Jan 9, 2018

Current design is to expose the source code via a code attribute:

~> f = { echo lorem }
~> echo $f[code]
{ echo lorem }

@xiaq xiaq added this to the 0.11 milestone Jan 9, 2018

@zzamboni

This comment has been minimized.

Contributor

zzamboni commented Jan 9, 2018

The attribute is fine, but maybe it would be more consistent to do this through the existing src function? E.g. src $f

@xiaq

This comment has been minimized.

Member

xiaq commented Jan 10, 2018

Yes, that will also be useful, but it's a slightly different thing: the src returns information about the entire source code. Consider this:

echo a; f = { put (src)[code] }

This will output echo a; f = { put (src)[code] }, not just the definition for f.

So we need to have both. As an alternative to your proposal, I'm also considering adding another src attribute.

@xiaq xiaq modified the milestones: 0.11, 0.13 Jan 14, 2018

@xiaq xiaq closed this in 62ab064 Mar 1, 2018

@zzamboni

This comment has been minimized.

Contributor

zzamboni commented Mar 1, 2018

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment