Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@msoeken
Copy link
Member

@msoeken msoeken commented Apr 7, 2022

Fixes #546 and removes all other occurrences of Default; also removes two warnings.

@msoeken msoeken requested a review from tcNickolas April 7, 2022 13:14
trainingSchedule : SamplingSchedule,
validationSchedule : SamplingSchedule
) : (SequentialModel, Int) {
mutable bestSoFar = Default<SequentialModel>()
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be worth an extended discussion. Before deprecating Default, it was somewhat of an idiom to use Default<UdtType>() w/ ItemName <- foo to kind of get named-item initializers instead of relying purely on positional construction. It may be good to have a language feature similar to Rust's {}-style structs as an alternative way of creating UDT values.


function ExampleModel() : ML.SequentialModel {
return Default<ML.SequentialModel>()
w/ Structure <- [
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly here, I think the original code was more readable even if less correct... from that perspective, I agree with your change but would like to kick off a discussion on more readable alternatives going forward?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that the original code was more readable. Do you suggest to keep the version using Default?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think getting rid of Default is worth temporarily having less readable code, so no disagreement with your PR so much as that I want to keep momentum on a longer-term solution, I guess?

mutable current = state;
mutable result = [Default<'State>(), size = Length(array)];
// initialize with current, and then overwrite in loop
mutable result = [current, size = Length(array)];
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need an early exit if array is empty, or is that implied by size = 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is implied by size = 0 since we do not need to access or compute some element based on the 0 index in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, wasn't entirely sure from a readthrough so wanted to double-check. Thanks!

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.

Refactor Mapped to avoid use of Default

3 participants