Skip to content

Allow invisible logical return values #135

Description

@krlmlr

All generics that return a logical should raise an error in case of failure (#51), and return TRUE otherwise (for compatibility). Because the return value is practically useless (at least in interactive mode), it should be invisible, but this is possible only if valueClass = "logical" is not defined for these generics.

It looks like lifting this requirement doesn't have an effect on existing backends.

Activity

  1. self-assigned this
    on Dec 1, 2016
  2. krlmlr commented on Dec 1, 2016

    @krlmlr
    MemberAuthor

    @hadley: Do you think d117262 is too much of an evil hack for DBI? I want generics like dbClearResult() to return invisibly, but this doesn't seem possible if the generic has a valueClass.

  3. hadley commented on Dec 1, 2016

    @hadley
    Member

    Yeah, it's too much of a hack.

    What's the problem with an invisibly return + valueClass = "logical" ?

  4. krlmlr commented on Dec 1, 2016

    @krlmlr
    MemberAuthor

    @hadley: This:

    > dbDisconnect
    standardGeneric for "dbDisconnect" defined from package "DBI"
      defined with value class: "logical"
    
    function (conn, ...) 
    {
        ans <- standardGeneric("dbDisconnect")
        .valueClassTest(ans, "logical", "dbDisconnect")
    }
    <environment: 0x56ef4c8>
    Methods may be defined for arguments: conn
    Use  showMethods("dbDisconnect")  for currently available ones.
    

    The .valueClassTest() call always returns a visible value. The only way I see around this is to omit valueClass (in this case there's no .valueClassTest() call), I guess I'm going to do that.

  5. hadley commented on Dec 1, 2016

    @hadley
    Member

    Oh got it.

    I think it's reasonable to omit the valueClass since the tests similarly enforce the API.

  6. added a commit that references this issue on Dec 2, 2016
  7. added a commit that references this issue on Dec 2, 2016
  8. added a commit that references this issue on Mar 10, 2017
  9. locked and limited conversation to collaborators on Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions