Skip to content

Unsafe API #24

@sirocchj

Description

@sirocchj

In many circumstances, as much as we'd like it to be, creating a safe protocol that is verifiable at compile time is just not possible.

One example would be when the Key needed in a get has to be constructed at runtime (say by appending together other string only available at runtime by consuming some external source).

In all these circumstances we may feel that the burden of having to prove the compiler we have valid Keys is just too big and what we really wish for is a good ol' RuntimeException, something that would just make us feel at peace with the universe...

I'm thinking something like:

trait UnsafeStringP { self: StringP =>
  final def get[A](key: String)(
      implicit ev: NonNullBulkString ==> A
  ): Protocol.Aux[Option[A]] = {
    require(key.nonEmpty, "why are you doing this to me now")
    self.get(Key.unsafeFrom(key))
  }
}

I'd also love to see this properly packaged under some very comforting namespace like hell or blinded (which I personally like a lot 'cause it plays well with laserdisc, i.e. import laserdisc.blinded._)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions