From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Check for redundancy Date: Fri, 03 Jul 2015 10:40:55 +0200 Organization: Informatimago Message-ID: <87si95iqg8.fsf@kuiper.lan.informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1435914052 26135 80.91.229.3 (3 Jul 2015 09:00:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Jul 2015 09:00:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 03 11:00:47 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZAwpb-00066L-VO for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Jul 2015 11:00:24 +0200 Original-Received: from localhost ([::1]:39868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAwb6-0007Qg-8P for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Jul 2015 04:45:24 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 138 Original-X-Trace: individual.net Sn3ZJRdPusZ025OYAJpIBgFzdAatOwqR5etXsvtX6H6vD3QGsy Cancel-Lock: sha1:YWVlOTU4NTA2YWY2ZDk2YmEwYmVhMzJmOWUzYjZlMWJkZGFjZTk1Mg== sha1:mjSyjM4u1VercUjFL+un+G0UkLY= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:213092 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105379 Archived-At: Robert Thorpe writes: > Emanuel Berg writes: > >> Robert Thorpe writes: >>> Just because there aren't types doesn't mean that >>> variables don't have types. What "untyped" means is >>> that the language doesn't enforce typing for you. >>> That makes it more important that you manage them >>> carefully for yourself. >> >> ... are you sure? >> >> In C, you do >> >> int five = 5; >> >> In Lisp (Elisp), you do >> >> (let ((five 5)) ...) > > I don't understand what this has to do with the issue. Both of the > languages here have types. C has static types and Lisp has latent (or > dynamic) types. Yes. And C is weakly typed, while Lisp is strongly typed: #include int main(void){ char a[]="hello"; int b=a+3; printf("%d\n",b); return 0; } prints some random garbage such as: -1309384925 status = 0 instead: (let* ((a "hello") (b (+ a 3))) b) Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p "hello") > What about assembly language? What about other languages with no type > system or a very limited type system? > >> If you want to, you can do (integerp five) > > In Lisp the type of a variable is stored with the variable at runtime. No, never, ever, not in a billion years. In lisp, types are not associated with variables, but with objects! There's nothing in the definition of the lisp language that would prevent this association to be performed at compilation time, in some cases at least. When in CL you declare a type naming a variable, what you are telling the computer, is that you promise you will never bind to that variable objects of a different type. But it's still the objects to which the type is associated, the objects bound to that variable, not the variable. > In C the type of a variable is recorded and enforced at compile time. Usually. There's nothing in the C langage definition that prevents run-time checks. On the contrary, most type casting are undefined or have implementation specific behaviors. For example, check the restrictions on using the variants of a union. > In many Assembly languages neither are done. You can't ask the variable > what it's type is and you can't ask the compiler either. The only > record is in your program and in your mind. Indeed, there are very few machines that associate type with the objects (the values). The only one coming to mind is the lisp machine processor, but IIRC, there may have been a few other machines with type tags. >> However, the way I understood HN is that you should >> *always* use prefixes like that. What I remembered it >> looked like this: >> >> intMoney = 0; >> strGreeting = "Stay a while, and listen!"; >> >> And I don't see any reason to do that. > > It's useful in assembly language programming. > > It's also useful in MS Window programming where everything is some kind > of handle. Even then though, I would only use it for the user > interface, not every variable as you say. The programmer must control its data flows, and therefore he should have an idea of what data goes into what variables and parameters. A tool useful for newbies is to control the type of those data flow, since often in a single function, you will have different types for different data flows. However, assigning compilation-time types or using hungarian notation has at least one big problem: this prevent generic programming, by constraining the types of your data much to early in general, What if now money is represented by its own class associating the currency with the amount, and if you live the USA, the origin of the money along with the required documentation, less the cops forfeit it. (So you see, it's very important to be able to switch to something of another type, notably for some users). (defun invest (intMoney) …) (invest (make-money :amount 10000 :currency :USD :origin (make-trace :explaination "Got a good salary last month." :source-name "My Employer Com" :source-address "Beyond Infinity Drive, 42\nYunque Bajo, CA92222" :document-url "http://my.employer.com/salaries/myself/2025/oct.xml"))) BANG! invest expected (why? for no reason!) an integer instead of some money. -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk