Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Equals: why the "=" (attribution) vs. "==" (Boolean) syntax distinction ???


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: RE: Equals: why the "=" (attribution) vs. "==" (Boolean) syntax distinction ???
Date   Tue, 27 Aug 2013 18:25:28 +0100

Not without a little sympathy, but....

It's for Stata's convenience, which ultimately means yours too. As =
means assignment and == asserts equality,  Stata needs a way of
keeping them straight.

As Joe implies, the alternative is some rule that tells you that =
means one thing in one place and another thing in another place. It's
not clear to me that anyone who gets tripped up by existing syntax
would not get tripped up by that. ("The first = means this, but the
second has a _quite_ different meaning....")

I've also encountered many positive reactions to this syntax when
users see that Stata is making a logical distinction between logically
different things.

Perhaps here the taste and logic of the language designer seem to be
triumphing over the taste and convenience of the beginning user, but
that's the way it goes. Heck, more advanced users have some rights
too!

I didn't know there were hard data anywhere on frequency of users' mistakes.


Nick
[email protected]


On 27 August 2013 18:10, Joe Canner <[email protected]> wrote:
> How about the following?
>
> . gen a=b==c
>
> How would Stata interpret this (valid) statement if there was no distinction between = and ==?
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Lucas Ferreira Mation
> Sent: Tuesday, August 27, 2013 1:00 PM
> To: statalist
> Subject: st: Equals: why the "=" (attribution) vs. "==" (Boolean) syntax distinction ???
>
> sort of a philosophical question (and I could not find any previous discussion on this topic in the list):
>
> why does Stata the language differentiate between "=" and "==" ?
>
> I was teaching a Intro to Stata Class and the students were asking about it. I explained the difference between attribution equal (=) and Boolean check equal (==).
>
> Although they got the concept, the question remains:
>
> why be explicit about this distinction in the language syntax?
>
> Thinking about it, it seems to me that the occurrences of "equal"
> (attribution vs. Boolean) aways appear in distinct places in the syntax, so it does not seem prone to mistakes.
>
> On the other hand, forgetting "==" it the single most common mistake beginner users make, and even more advanced users ofter forget.
>
> Anyway, I just wanted to know if there are other reasons I'm unaware of.
>
>
> Lucas
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index