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

Move $ and == for objects out of system #475

Open
metagn opened this issue Aug 14, 2022 · 1 comment
Open

Move $ and == for objects out of system #475

metagn opened this issue Aug 14, 2022 · 1 comment

Comments

@metagn
Copy link
Contributor

metagn commented Aug 14, 2022

Abstract

Move the overloads for the symbols $ and == for generic object types out of system into a new module.

Motivation

Objects are nominal types that often overload these procs. This can cause problems with uses of them in generic/template code that don't mix them in, and statically use the system module overload of them for objects. There were some open issues of this but it's hard to find them.

== for objects also has a limitation where, since it's defined in system, it can't use complex macro code, which means it can't support case objects easily since fieldPairs is unavailable for case objects (nim-lang/Nim#6676).

Also in general people might not want their object types to have a default $/== overload like this. But sometimes they will, and they can have this by just importing the new module these would be in.

Description

$ implementation, == implementation

Notice the implementation is the same for tuples and objects. One option is to move these implementations to a private module, then export specialized versions for tuples and objects in separate modules.

Inspired by nim-lang/Nim#20185.

Code Examples

No response

Backwards Compatibility

This would be part of -d:nimPreviewSlimSystem. Any backwards compatibility issues are the same as the rest of the umbrella of that flag.

@juancarlospaco
Copy link
Contributor

But should be added to prelude.

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

No branches or pull requests

2 participants