Skip to content
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

[Booleans] new concept #781

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

colinleach
Copy link
Contributor

For discussion on the forum.

This concept draft borrows heavily from exercises/concept.wip/.docs/introduction.md, with some edits and new additions. It pairs with annalyns-infiltration.

concepts/booleans/about.md Outdated Show resolved Hide resolved
concepts/booleans/about.md Outdated Show resolved Hide resolved
concepts/booleans/about.md Outdated Show resolved Hide resolved
true
```

Because `5 > 12` is `false`, clearly the combined expression must be `false`.
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe we can say the combined expression is clearly false since we haven't introduced why the expression would be false. We also risk reinforcing whatever interpretation the student got from line 85 because they might think Julia stops when it hits a false value regardless of which operator is used so that's what "unambiguous" means.

```

Because `5 > 12` is `false`, clearly the combined expression must be `false`.
The `1 != 0` expression is not relevant and is never evaluated.
Copy link
Member

Choose a reason for hiding this comment

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

1 != 0 isn't evaluated when the left side evaluates to false. It is evaluated if the left side evaluates to true so we can't say it's never evaluated without qualifying that never.

concepts/booleans/introduction.md Outdated Show resolved Hide resolved
true
```

Parentheses are optional and can make the code easier to read.
Copy link
Member

Choose a reason for hiding this comment

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

This should be included under the logical OR section. However, we've already mentioned this in the Boolean logic section so it can be dropped.


In Julia (and many other programming languages), `&&` has a [higher precedence][operator-precedence] than `||` (in the same way that `*` is applied before `+`).
This means that `true || false && true` evaluates to `true` because it is parsed as `(true || false) && true`.
It is common to include explicit brackets anyway so that the reader doesn't need to think about this.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It is common to include explicit brackets anyway so that the reader doesn't need to think about this.
It is common to include explicit parentheses anyway so that the reader doesn't need to think about this.

colinleach and others added 2 commits September 9, 2024 13:23
@colinleach
Copy link
Contributor Author

I need to think about this and try again.

@colinleach
Copy link
Contributor Author

colinleach commented Sep 9, 2024

Your key point is that comparison operators aren't taught till the next concept. I'm a bit less worried about this in about.md, which is allowed to forward-reference, but these should definitely be removed from introduction.md.

One take-home message: don't blindly reuse text from the older exercise drafts, as I did here.. There are reasons why this syllabus hasn't launched.

I'll think about this, and try again tomorrow.

@colinleach
Copy link
Contributor Author

I did a major rewrite (essentially from scratch) of both Markdown files, in response to the all-too-valid criticisms from @BNAndras.

Further comments welcome, from anyone.

Copy link
Member

@BNAndras BNAndras left a comment

Choose a reason for hiding this comment

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

Not at a computer but these jumped out at me.

Only expressions which evaluate to `true` or `false` will be treated as a `Bool`.

Specifically, empty arrays or strings will *not* be interpreted as `false`.
There must be an appropriate test such as `isempty()` if you want special handlind for empty values.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There must be an appropriate test such as `isempty()` if you want special handlind for empty values.
There must be an appropriate test such as `isempty()` if you want special handling for empty values.

true
```

These operators will be familiar to users of many other languages, though *not* Python.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence is confusing. and and or exist in other languages. Perhaps we say the operators and these concepts should be familiar coming from other languages but they might have different names there.

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.

2 participants