Skip to content

Conversation

@beef331
Copy link
Collaborator

@beef331 beef331 commented Feb 17, 2021

Adds complement for builtin sets which inverts the set. Adds fullset by extension as it was required. Breaks the JS testing for an unevident reason.

(EDIT)

notes

proc fullSet*(T: typedesc): auto {.inline.} =
=>
proc fullSet*(T: typedesc): set[T] {.inline.} = would give a BUG

@timotheecour
Copy link
Member

timotheecour commented Feb 18, 2021

IMO the only thing left here is decide whether to use not or something else (eg complement)

IMO complement is preferred for clarity, there's not much value in conflating logical not with set not; the only (or main) times where it makes sense to reuse a name is where it helps generic code, but I can't think of a single non-contrived case where this would hold in this case.

Please vote with a reaction to this comment:

  • -1 for keeping not
  • +1 for using something different (complement or something else)

note

this is related to nim-lang/RFCs#102; IMO or, not etc for integers should've been bitor, bitnot etc (more searchable); while this may (or not) be too late for those operators, we shouldn't make this worse by extending this to set. refs also #11372 (comment)

@timotheecour timotheecour changed the title Add setutils.not Add setutils.not, stutils. fullset Feb 18, 2021
@timotheecour timotheecour changed the title Add setutils.not, stutils. fullset Add setutils.not, stutils.fullset Feb 18, 2021
@timotheecour timotheecour changed the title Add setutils.not, stutils.fullset Add setutils.not, stutils.fullSet Feb 18, 2021
@konsumlamm
Copy link
Contributor

konsumlamm commented Feb 18, 2021

IMO complement is preferred for clarity, there's not much value in conflating logical not with set not; the only (or main) times where it makes sense to reuse a name is where it helps generic code, but I can't think of a single non-contrived case where this would hold in this case.

Note that not is also used for bitwise complement for integer types (https://nim-lang.org/docs/system.html#not%2Cint).

P.S.: There is a typo in the title, it should be "setutils.fullSet".

@beef331 beef331 changed the title Add setutils.not, stutils.fullSet Add setutils.not, setutils.fullSet Feb 18, 2021
@timotheecour
Copy link
Member

timotheecour commented Feb 18, 2021

Note that not is also used for bitwise complement for integer types (nim-lang.org/docs/system.html#not%2Cint).

yes, but that's an IMO unfortunate historical artifact that we shouldn't make worse, see nim-lang/RFCs#102

@beef331
Copy link
Collaborator Author

beef331 commented Feb 18, 2021

I'd say the best name to be is invert or inverted just so it's a more likely to be understood name. complement is rather obscure to the uninitiated.

@timotheecour
Copy link
Member

timotheecour commented Feb 18, 2021

I'd say the best name to be is invert or inverted just so it's a more likely to be understood name. complement is rather obscure to the uninitiated.

IMO complement the most commonly accepted terminology, by far, eg https://en.wikipedia.org/wiki/Complement_(set_theory) and lots of other sources.

set inverse returns much fewer hits on google than set complement, and also the top hits don't refer to this notion.

@Araq
Copy link
Member

Araq commented Feb 18, 2021

Yes, it should be complement.

@beef331
Copy link
Collaborator Author

beef331 commented Feb 18, 2021

Well since the consensus seems to be to (ironically) not use not, renamed it.

@beef331 beef331 changed the title Add setutils.not, setutils.fullSet Add setutils.complement, setutils.fullSet Feb 18, 2021
Copy link
Member

@timotheecour timotheecour left a comment

Choose a reason for hiding this comment

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

nice

@beef331 beef331 marked this pull request as ready for review February 18, 2021 07:43
@timotheecour timotheecour removed the Vote label Feb 18, 2021
@timotheecour
Copy link
Member

@beef331 CI fails, see #17066 (comment) for final recommendation before this can be merged

@timotheecour timotheecour added the merge_when_passes_CI mergeable once green label Feb 18, 2021
@timotheecour
Copy link
Member

timotheecour commented Feb 18, 2021

@beef331 CI still fails, after investigating in #17095, it's because defined(bsd) will be false in js mode, so there's no simple way via testament to selectively disable a block (timotheecour#598 would make it easy though, yet another use case)

so I suggest for now to do the more coarse disabling instead:

discard """
  targets: "c js"
  disabled: "bsd" # pending #17093
"""

@timotheecour
Copy link
Member

timotheecour commented Feb 19, 2021

@beef331 good that it's green for the 1st time :) I finally figured out the mysterious CI failure for freebsd/openbsd, see #17097; TLDR: builds.sr.ht CI doesn't work like the other CI causing issues for github projects.

The fix here (so we could un-disable bsd) would be to rebase this PR against devel, which would pick up the fix for #17076 (shouldn't be needed for other CI because they merge against latest devel on each PR push, but it's needed for builds.sr.ht CI)

I'll go ahead and merge this to avoid too many ping pong and will followup with another PR to do this.

EDIT => #17098

@timotheecour timotheecour merged commit 35ded02 into nim-lang:devel Feb 19, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge_when_passes_CI mergeable once green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants