Skip to content

Conversation

@JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Sep 9, 2025

Pull Request Description

  • proposing a compatible API change in Any and Warning types
    • there shall be no API change when Warning module is imported
    • which means no change when from Standard.Base import all
  • Inspired by the work to formalize method dispatch. In gene
  • We shouldn't "stuff methods" into Any - e.g. extend root class
  • rather we should use extension methods with a classical pattern
Any.is_magical self = False
My_Magic.is_magical self = True
  • that way we guarantee is_magical is available on every object to everyone importing My_Magic
  • people that don't import about My_Magic aren't "disturbed" by such extensions

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    style guides.
  • Unit tests continue to work

@JaroslavTulach JaroslavTulach self-assigned this Sep 9, 2025
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Sep 9, 2025
@JaroslavTulach JaroslavTulach marked this pull request as draft September 9, 2025 17:52
@github-actions github-actions bot added the -libs-API-change-Base Marks a PR that changes the public API of Standard.Base label Sep 10, 2025
@JaroslavTulach JaroslavTulach marked this pull request as ready for review September 10, 2025 06:15
@enso-bot
Copy link

enso-bot bot commented Sep 10, 2025

Jaroslav Tulach reports a new STANDUP for yesterday (2025-09-09):

Progress: .

@JaroslavTulach
Copy link
Member Author

If the approach of this PR is found sane, then we could continue with Nothing.diff.gz. Again compatible when from Standard.Base import all, but as the diff shows, a lot of imports would have to be fixed to make it work when importing individual modules.

@JaroslavTulach
Copy link
Member Author

If the approach of this PR is found sane, then we could continue with Nothing.diff.gz. Again compatible when from Standard.Base import all, but as the diff shows, a lot of imports would have to be fixed to make it work when importing individual modules.

Thanks for the approval James. Let's integrate the warnings part. What's is your opinion about the Nothing methods move?

@JaroslavTulach JaroslavTulach merged commit 708f2e8 into develop Sep 11, 2025
74 of 78 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/WarningExtensionMethods branch September 11, 2025 06:25
@jdunkerley
Copy link
Member

Thanks for the approval James. Let's integrate the warnings part. What's is your opinion about the Nothing methods move?

I think I disagree on Nothing as view that as part of the absolute language core - Any, Text, Nothing, Number and Boolean feel the core types of language and is_nothing and if_nothing are the core methods. I guess other Nothing method can be remove from Any if needed.

@enso-bot
Copy link

enso-bot bot commented Sep 12, 2025

Jaroslav Tulach reports a new STANDUP for yesterday (2025-09-11):

Progress: .

GitHub
Pull Request Description Semi-formal spec for method resolution and evaluation. Important Notes

Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:

...

@JaroslavTulach
Copy link
Member Author

Any, Text, Nothing, Number and Boolean feel the core

Ok. That's valid view.

@jdunkerley jdunkerley added this to the 2025.3 Release milestone Oct 1, 2025
mergify bot pushed a commit that referenced this pull request Oct 9, 2025
- in the tradition of #14017
- and previous  #13978
- and #14003
- and #14004
- let's make Enso less _"to text oriented"_ language
- there should be **no API change** for those who `from Standard.Base import all`

# Important Notes
- coming from Java with its [Object.toString](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Object.html#toString()) - one might be fine with `to_text` in `Any`
- however `pretty` and `to_display_text` clearly seem weird
- moreover my object oriented roots are in [Turbo Pascal 5.5](https://en.wikipedia.org/wiki/Turbo_Pascal#Object-oriented_programming)
- the root object there - the `TObject` had no methods at all!
- while _clean_ (e.g. Turbo Pascal was no "[something oriented language](https://wiki.apidesign.org/wiki/RootClass)", but trully _just an object oriented language_) - I don't call for that in case of Enso
- ultimatelly I'd like Enso to be _"conversion oriented language"_ - e.g. `Any.to` is perfectly fine in the [root type](https://wiki.apidesign.org/wiki/RootClass)
- with all the _extension method_ capabilities Enso has, I believe moving `to_display_text`, `pretty`  out of `Any` is a completely legitimate goal
mergify bot pushed a commit that referenced this pull request Oct 12, 2025
Enso, at it roots, is a **conversion oriented language**. Enso supports flexible definitions of conversions of values of a type to another. To stress the importance of conversions in usage of the Enso language, there is `Any.to target_type` method available on any value in the Enso system that allows to _morph and view any object as a different type_ easily when such a conversion is available.

In addition to that Enso is **structured equality oriented language**. There is `Any.==` operator that allows any two values to be compared for equality. The comparison is based on structure - e.g. two instances of the same atom with equal fields are the same. Enso provides such a _structured equality_ implementation to every user defined type automatically, yet it also offers more complex equality handling when needed (via `Comparable` type).

Enso is **conversion and** (structured) **equality oriented language**. That fact is stressed by the shape of its root type `Any`. It exposes just `.to`, `==` and `!=` operations.

# Important Notes
- To fulfill the promise of Enso being  **conversion and equality oriented language**
- this PR proposes to turn `Nothing` related methods into _extension methods_
- e.g. to move them out of `Any` type into `Nothing` type
- the change is supposed to be compatible for everyone using `from Standard.Base import all`
- this PR is the final step finishing the work previously started by
- #14004
- #14003
- #13978
- #14017
- #14050
- in the tradition of those PRs let's argue:
- it is better to be somebody, or at least anybody - nobody wants to feel like `Nothing`
- hence we don't want Enso to feel like "nothing oriented language"
- as such `Nothing` related methods should be provided only as extension methods!
- on a more technical note: `obj.is_nothing.not` can actually be written as `obj!=Nothing`, not sure why we prefer the former (and longer) variant? Maybe some FP bias!?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

-libs-API-change-Base Marks a PR that changes the public API of Standard.Base CI: No changelog needed Do not require a changelog entry for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants