Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Nov 19, 2018

No description provided.

@Keno Keno requested review from JeffBezanson and vtjnash November 19, 2018 15:15
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know—this seems like an implementation detail that we don't want people to depend upon

return Const(isdefined((arg1::Const).val, idx))
elseif isa(arg1, Const)
arg1v = (arg1::Const).val
if isimmutable(arg1v) || (isa(arg1v, DataType) && is_dt_const_field(idx))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be:

if isimmutable(arg1v) || isdefined(arg1v, idx)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, not quite, because you do want false here if .instance is not defined. However, since it shouldn't be possible to undefine a field, I think isimmutable(arg1v) || isdefined(arg1v, idx) || (isa(arg1v, DataType) && is_dt_const_field(idx)) would be ok.

end
add_tfunc(<:, 2, 2, subtype_tfunc, 0)

is_dt_const_field(fld) = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you missed @nospecialize here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or rather, I'm missing ::Int.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. Last time I looked, I think we were missing that check in the caller, but looks like we now ensure it is an Int.

@Keno
Copy link
Member Author

Keno commented Nov 19, 2018

I don't know—this seems like an implementation detail that we don't want people to depend upon

Fair, but is that a reason to intentionally make it slower?

@vtjnash
Copy link
Member

vtjnash commented Nov 19, 2018

Fair, but is that a reason to intentionally make it slower?

Perhaps? It makes some of the code more complex, and as they say "writing code is writing bugs". Also perhaps not as useful to optimize a code smell pattern that we might want to explicitly discourage (since only a subset of objects have this field defined, and the user should be tracking values not Types). But anyways, I won't block the PR over it.

@Keno Keno merged commit 9f43871 into master Nov 20, 2018
@maleadt maleadt deleted the kf/dtypetfunc branch November 20, 2018 07:14
tkf pushed a commit to tkf/julia that referenced this pull request Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants