# Naming of 'weak' type hints

- Thread: https://externals.io/message/85555
- Original archive: https://news-web.php.net/php.internals/85555
- Started by Zeev Suraski on 2015-03-30T14:16:50+00:00
- Messages: 16
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #85555 — Zeev Suraski — 2015-03-30T14:16:50+00:00

URL: https://externals.io/message/85555#85555

All,



One thing that I think we should change is how we refer to the ‘weak’ type
hints.  The word ‘weak’ has a negative ring to it, and considering this is
how the language behaves across the board it’s a pretty bad name for this
feature.



Personally I think we should go for ‘dynamic’ when we document it, as this
is the common way to refer to this behavior (dynamic languages).  We could
also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
although I think we can easily do without introducing a new word into the
vocabulary here.



Thoughts?



Zeev

---

## #85556 — Dan Cryer — 2015-03-30T14:24:02+00:00

URL: https://externals.io/message/85555#85556 · In reply to: #85555

>
> We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.
>

From an user perspective, I'd suggest that "lax" would potentially carry
more negative connotations than "weak." Lax implies (to me) that the engine
is being negligent in not checking the types...

Dynamic for "weak" types, and Strong for "strict" types would make the most
sense to me. :)

---

## #85557 — Florian Margaine — 2015-03-30T14:35:23+00:00

URL: https://externals.io/message/85555#85557 · In reply to: #85555

Hi Zeev,

Le 30 mars 2015 16:17, "Zeev Suraski" <zeev@zend.com> a écrit :
>
> All,
>
>
>
> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.
>
>
>
> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.

Dynamic is used in the context of static/dynamic typing though, and that's
a different meaning. Strong/weak typing is a known definition, and the
correct one here.

>
>
>
> Thoughts?
>
>
>
> Zeev

---

## #85558 — Chris Wright — 2015-03-30T14:41:29+00:00

URL: https://externals.io/message/85555#85558 · In reply to: #85555

> All,
>
>
>
> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.
>
>
>
> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.
>
>
>
> Thoughts?
>
>
To me, "dynamic" implies "subject to change". The rules are different but
they are fixed and well defined.

I would suggest "loose" if you want to avoid "weak" (personally I think
"weak" is OK, but I can certainly see where you are coming from). "Loose
typing" is not new terminology, indeed Google seem to consider it
synonymous with "weak typing" - when I Google either the first hit is
http://en.wikipedia.org/wiki/Strong_and_weak_typing


>
>
> Zeev

---

## #85562 — Christoph Becker — 2015-03-30T16:30:06+00:00

URL: https://externals.io/message/85555#85562 · In reply to: #85555

Zeev Suraski wrote:

> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.

> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.

It appears to me that all of these suggestions may hide the fact that
the arguments are converted to the hinted types.  So perhaps "converting
type hints" might be a good name.

Then again, the respective declare directive is called "strict_types",
so maybe it's best to speak of "non-strict type hints".

-- 
Christoph M. Becker

---

## #85563 — Stanislav Malyshev — 2015-03-30T17:44:11+00:00

URL: https://externals.io/message/85555#85563 · In reply to: #85555

Hi!

> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is

I would really prefer we stop calling it "hints". It is misleading as it
is implying this is something which can be easily ignored if wished and
only provides an unimportant small piece of information not directly
related to the important things. In fact, it would either change the
type of the value or produce fatal error, it's hardly a "hint".
-- 
Stas Malyshev
smalyshev@gmail.com

---

## #85569 — Lazare Inepologlou — 2015-03-30T22:00:38+00:00

URL: https://externals.io/message/85555#85569 · In reply to: #85562

Zeev Suraski wrote:

> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.

Borrowing from C#, I would suggest the names implicit and explicit argument
types. There is nothing "weak" about them, they just do an implicit
conversion which can be quite powerful if used correctly.

In the future, I hope that we will have implicit object conversions in
addition to the scalar ones.



Lazare INEPOLOGLOU
Ingénieur Logiciel

---

## #85573 — Robert Stoll — 2015-03-30T23:46:31+00:00

URL: https://externals.io/message/85555#85573 · In reply to: #85569

> -----Ursprüngliche Nachricht-----
> Von: Lazare Inepologlou [mailto:linepogl@gmail.com]
> Gesendet: Dienstag, 31. März 2015 00:01
> An: Christoph Becker
> Cc: Zeev Suraski; PHP internals
> Betreff: Re: [PHP-DEV] Re: Naming of 'weak' type hints
> 
> Zeev Suraski wrote:
> 
> > […]
> 
> Borrowing from C#, I would suggest the names implicit and explicit argument types. There is nothing "weak" about them,
> they just do an implicit conversion which can be quite powerful if used correctly.
>

[Robert Stoll] 
It's probably hard to come up with something which does not conflict with another concept, but implicit and explicit typing is used to refer to two sub categories of static typing. Explicit typing refers to code which requires explicit type specifications written by the user and implicit typing is the case where type inference infers the types.

I am not so sure if it is clever to use an own name for type hints when strict_types=1 since the type hint as such is not different, the context is different. I am think about it in the sense that a function has different overloads and depending on the context some are available and others are not (similar to the callee of a method call, strict_types=1 can be seen as another argument). But I guess that is too complicated for a documentation. Nevertheless, I would put emphasis on the fact that the context is different. 

> In the future, I hope that we will have implicit object conversions in addition to the scalar ones.

[Robert Stoll] 
That would be nice :)

> 
> 
> 
> Lazare INEPOLOGLOU
> Ingénieur Logiciel

---

## #85579 — pajousek@gmail.com — 2015-03-31T08:42:39+00:00

URL: https://externals.io/message/85555#85579 · In reply to: #85555

> All,
>
>
>
> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.
>
>
>
> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.
>
>
>
> Thoughts?
>
>
>
> Zeev


Hello,

I would definitely stick with "weak"; it is common naming used across
many languages and textbooks.

Also, why is the strongly typed mode named "strict" anyways? If
anything should change, it should be strict to strong, so PHP doesn't
look like a special snowflake.

Regards
Pavel Kouril

---

## #85580 — Lester Caine — 2015-03-31T09:01:39+00:00

URL: https://externals.io/message/85555#85580 · In reply to: #85555

> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.

soft and hard?

And as long as we don't add any hints it is still 'no type hinting' ?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #85583 — francois@php.net — 2015-03-31T13:32:15+00:00

URL: https://externals.io/message/85555#85583 · In reply to: #85555

> De : Zeev Suraski [mailto:zeev@zend.com]
> 
> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.

What about 'loose' vs 'strict' type hinting ?

---

## #85584 — Terry Cullen — 2015-03-31T13:52:55+00:00

URL: https://externals.io/message/85555#85584 · In reply to: #85555

> All,
>
>
>
> One thing that I think we should change is how we refer to the ‘weak’ type
> hints.  The word ‘weak’ has a negative ring to it, and considering this is
> how the language behaves across the board it’s a pretty bad name for this
> feature.
>
>
>
> Personally I think we should go for ‘dynamic’ when we document it, as this
> is the common way to refer to this behavior (dynamic languages).  We could
> also consider going for ‘lax’ or ‘lenient’ as the opposite of ‘strict’,
> although I think we can easily do without introducing a new word into the
> vocabulary here.
>
>
>
> Thoughts?
>
>
>
> Zeev
>

Coercive?


-- 


Regards,

Terry Cullen
Freelance Senior PHP Programmer/Web Developer
--
Phone 1300-955-838 <+61-1300-955-838>Mobile 04-3836-8032 <+61-4-3836-8032>
Email terry@terrycullen.com.auWeb http://www.terrycullen.com.au/G-Talk
terry@terrycullen.com.au13 Jarrott St, ChelmerTerah Pty Ltd | ACN 135 365
552 <http://www.terrycullen.com.au/>[image: Terah Pty Ltd logo]
<http://www.terrycullen.com.au/

---

## #85586 — Jeremy Mikola — 2015-03-31T13:57:13+00:00

URL: https://externals.io/message/85555#85586 · In reply to: #85584

On Monday, March 30, 2015, Christoph Becker <cmbecker69@gmx.de
<javascript:_e(%7B%7D,'cvml','cmbecker69@gmx.de');>> wrote:

>
> It appears to me that all of these suggestions may hide the fact that
> the arguments are converted to the hinted types.  So perhaps "converting
> type hints" might be a good name.


"Coercive" may be a concise term, without the negative connotation of
weak/lax.


-- 
jeremy mikola

---

## #85590 — Anthony Ferrara — 2015-03-31T15:19:22+00:00

URL: https://externals.io/message/85555#85590 · In reply to: #85579

Pavel,

> Hello,
>
> I would definitely stick with "weak"; it is common naming used across
> many languages and textbooks.
>
> Also, why is the strongly typed mode named "strict" anyways? If
> anything should change, it should be strict to strong, so PHP doesn't
> look like a special snowflake.

Strong has a very specific meaning, which PHP is not using. For
example, Python variables are strongly typed (meaning it's restrictive
about how types are intermingled). So while "x" + 3 in JavaScript
(another weakly typed language) is "x3", in python it would be a type
error (assuming "x" + 3).

PHP's overall type behavior is still weak at the variable level. The
difference is that strict type declarations require types to match at
the point of parameter passing. But it doesn't make the variable
strongly typed.

As far as "weak", that's the description of the type system in
general. However as far as type declarations are concerned, I think it
would be fair to talk about the two modes as "coercive" and "strict".

Anthony

---

## #85626 — Stanislav Malyshev — 2015-04-01T07:11:59+00:00

URL: https://externals.io/message/85555#85626 · In reply to: #85590

Hi!

> general. However as far as type declarations are concerned, I think it
> would be fair to talk about the two modes as "coercive" and "strict".

I think this is a good option.
-- 
Stas Malyshev
smalyshev@gmail.com

---

## #85627 — Zeev Suraski — 2015-04-01T07:15:53+00:00

URL: https://externals.io/message/85555#85627 · In reply to: #85626

> -----Original Message-----
> From: Stanislav Malyshev [mailto:smalyshev@gmail.com]
> Sent: Wednesday, April 01, 2015 10:12 AM
> To: Anthony Ferrara; Pavel Kouřil
> Cc: Zeev Suraski; PHP internals
> Subject: Re: [PHP-DEV] Naming of 'weak' type hints
>
> Hi!
>
> > […]
>
> I think this is a good option.

Seems like this is the one that has the most supporters and I agree it makes
sense.  +1 from me.

Zeev
