Skip to content

Export @compute at the top level #4529

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

Closed
wants to merge 1 commit into from
Closed

Export @compute at the top level #4529

wants to merge 1 commit into from

Conversation

tomchor
Copy link
Collaborator

@tomchor tomchor commented May 20, 2025

I wonder what people think of this. I find this macro really useful and always find myself using it, getting an error that @compute is not defined, and then (properly) using it!

@simone-silvestri
Copy link
Collaborator

simone-silvestri commented May 20, 2025

As I understand now, @compute is equivalent to compute!.
i.e.

@compute f = Field(op)

is equivalent to

f = compute!(Field(op))

I think a good change would be to make @compute also construct the field, in practice, having

f = @compute op

as to cover another functionality that can be exported

@glwagner
Copy link
Member

What about calling compute! in the Field constructor?

@simone-silvestri
Copy link
Collaborator

simone-silvestri commented May 20, 2025

Sounds like a good idea. We could add a keyword argument to

function Field(operand::OperationOrFunctionField;
data = nothing,
indices = indices(operand),
boundary_conditions = FieldBoundaryConditions(operand.grid, location(operand)),
recompute_safely = true)
grid = operand.grid
loc = location(operand)
indices = validate_indices(indices, loc, grid)
@apply_regionally boundary_conditions = FieldBoundaryConditions(indices, boundary_conditions)
if isnothing(data)

which defaults to true.

@glwagner
Copy link
Member

See #4531

@tomchor
Copy link
Collaborator Author

tomchor commented Jun 11, 2025

Superseded by #4531

@tomchor tomchor closed this Jun 11, 2025
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.

3 participants