Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

[WIP] Make merge typestable #29

Closed
wants to merge 1 commit into from

Conversation

davidanthoff
Copy link
Collaborator

This doesn't work and it is probably because I'm misusing generated functions once again, but I don't really understand why this is not working. The way I think this should work is this:

using NamedTuples

A = @NT(a=2)
B = @NT(b=2)

merge(A,B)

I get an error message "ERROR: eval cannot be used in a generated function" from that. But, as far as I can tell I'm actually not calling eval in the generated function, all I'm doing is I'm returning a quoted expression that has a macrocall to @NT in it. Now the @NT macro calls eval (sometimes), so I assume that is the problem? Any other ideas for this situation?

@JeffBezanson @vtjnash @shashi

@shashi
Copy link

shashi commented May 15, 2017

the @NT macro calls eval (sometimes)

Exactly. It's ok to use @NT in a @generated function if the type already exists (because then it won't call eval), but not ok to use it in the merge case where unless you're merging 2 types of the same fields, the output type is a new type. As you stated in #27 this can be fixed by . overloading, or by making named tuples a more primitive Base feature like Tuple.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants