Skip to content

Trial: Go back to witness syntax #7928

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

Closed
wants to merge 2 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 8, 2020

This is an attempt to validate the current given design against my very first proposal
from more than a year ago: witnesses. I have duplicated the docs, replacing syntax
and terminology.

To get started with browsing: https://github.com/dotty-staging/dotty/blob/try-witness/docs/docs/reference/contextual-witnesses/motivation.md

This is an attempt to validate the current given design against my very first proposal
from more than a year ago: witnesses. I have duplicated the docs, replacing syntax
and terminology,
@jducoeur
Copy link
Contributor

jducoeur commented Jan 8, 2020

I still think it doesn't read as idiomatic English -- I don't know anybody outside of hardcore computer science who ever uses the word "witness" like that. Can't speak for the rest of the world, but I personally don't think it would teach well to native English speakers...

@odersky
Copy link
Contributor Author

odersky commented Jan 8, 2020

@jducoeur

https://english.stackexchange.com/questions/167683/witness-to-vs-witness-of/168408
https://forum.wordreference.com/threads/witness-of-to.2600118/
https://www.youtube.com/watch?v=nAvH8I7o8Ek

The noun form is "witness of". So this looks like idiomatic english to me. It might be rarely used in common language, but that's OK as far as I am concerned. We are talking about a concept that will be novel to new users. So it's OK to use an uncommon term and fill it with meaning.

@odersky
Copy link
Contributor Author

odersky commented Jan 8, 2020

Also: the very first example in Merriam Webster says:

the ruins are a compelling witness of the ancient civilization's cultural and aesthetic achievements

https://www.merriam-webster.com/thesaurus/witness

@jducoeur
Copy link
Contributor

jducoeur commented Jan 8, 2020

Sure, but that's a fine example of what I mean: that's essentially an archaic form of speech. It would have sounded entirely normal a century ago, and a bit quaint when I was a child, but the language has evolved rapidly since then. I can't remember seeing a sentence like that outside of academia or religion in recent decades, and rarely even there.

I'm using "idiomatic" quite precisely here. It is legal English -- but so is all of Shakespeare. It isn't how people actually use the language in regular practice any more, though. In practice, the non-verb form "witness" is rarely used except when describing a human being, and even that not especially often outside of a courtroom...

@tellurion
Copy link

While witness isn't commonly used out of legal settings, it works well with the term evidence, which the compiler currently uses. And it is grammatically correct. I still don't like them because they are used to suggest or talk about something abstractly and not used in a concrete sense.
I do think a term like provide would work better with given.
e.g. The clause provide Ord[Int] { ... } would read as "provide this Ord of Int to compiler" and the clause (given Ord[Int]) would read as "given that an Ord of Int has been provided." I think provide (or a similar, more solid term) and given communicate both intent and what is actually happening better.

@SethTisue
Copy link
Member

SethTisue commented Jan 9, 2020

(at this point I don't have a clear overview in my head of all the different possibilities and their pros and cons, so I can't confidently say what I think is best, big-picture, but regardless:)

I would love it if we can find a noun that isn't "given". I have tried, but I have been unable to get used to talking/thinking about "givens" as a thing. I'm delighted to hear that choosing a different noun is still a possibility (I'd sort of "given" up on it). perhaps "witness" isn't the perfect noun; perhaps there isn't any perfect noun; but IMO it's a better noun than "given"

@jducoeur I don't know anybody outside of hardcore computer science who ever uses the word "witness" like that

the important thing is not to give a clear impression that is also a wrong impression. I think "witness" doesn't give a clear but wrong impression; rather, it gives a "hmm, what's that, tell me more" impression and that's okay:

@odersky it's OK to use an uncommon term and fill it with meaning

agree

@godenji
Copy link

godenji commented Jan 9, 2020

/s/witness/instance would work. I agree with @jducoeur that the usage of witness here doesn't read particularly well, but it could work.

The important piece is finding the right terminology to transform the world of Scala 2 implicits such that whatever new keyword(s) are added somehow convey the semantics of use. For example, with typeclasses instance is a natural fit, and given also works quite well as a replacement for implicit parameters, but these two terms are perhaps not enough to capture the range of functionality provided by Scala implicits.

Side note: the multi-soft keyword approach term ... of ... with {} is a bit unpleasant; what's the resistance to adding one or two hard keywords to the language, particularly for such an important area as implicits?

@odersky
Copy link
Contributor Author

odersky commented Jan 12, 2020

My evaluation so far:

  • witness works pretty well for one half of the implicit universe: typeclasses and other typelevel computatoons.
  • It's a bit of a stretch for context parameters. Might sound a tad too archaic to call an implicit ExecutionContext a "witness of ExecutionContext". But one could probably get used to it over time, when the novelty wears off.

@bmeesters
Copy link

Outside the Scala community, Scala is often regarded as an 'academic' language. This is not a view I agree with, but it is also not something we should ignore. Using keywords like witness is bound to strengthen this view, rather than diminish it.

Personally, I don't care that much about which keyword is chosen and I could get used to witness. However, I am already hooked to Scala, and I think things like witness might be off-putting to potential new Scala developers.

@kavedaa
Copy link

kavedaa commented Jan 15, 2020

I'm not sure if it's been suggested before, but evidence of could be an alternative to witness of.

Pros:

  • evidence is less archaic
  • metaphorically it's more concrete and "solid"
  • if witness were to be combined with the with form, their likeness (wit-) could be confusing

Cons:

  • it's a bit awkward to talk about "evidences", in contrast to "witnesses" (better: "evidence instances")

I'd like to add that I think the of form works better than the as form. witness/evidence of Foo makes sense grammatically, but given as Foo doesn't quite.

@odersky
Copy link
Contributor Author

odersky commented Jan 18, 2020

I decided to pursue #8017 instead.

@odersky odersky closed this Jan 18, 2020
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

Successfully merging this pull request may close these issues.

7 participants