Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!cis.ohio-state.edu!math.ohio-state.edu!uwm.edu!fnnews.fnal.gov!gw2.att.com!nntpa!ssbunews!ssbunews.ih.att.com!lgm
From: lgm@polaris.ih.att.com (Lawrence G. Mayka)
Subject: Re: local methods??
In-Reply-To: swm@harlequin.com's message of 15 Mar 1995 12:12:35 -0500
Message-ID: <LGM.95Mar26154718@polaris.ih.att.com>
Sender: news@ssbunews.ih.att.com (Netnews Administration)
Nntp-Posting-Host: polaris.ih.att.com
Organization: AT&T Bell Laboratories, Naperville, Illinois, USA
References: <Johan.Dahl-1203950332470001@venus.ling.lu.se>
	<26340.199503151707@phaedrus.harlequin.com>
Date: Sun, 26 Mar 1995 21:47:18 GMT
Lines: 63

In article <26340.199503151707@phaedrus.harlequin.com> swm@harlequin.com (Scott McKay) writes:

      Date: Sun, 12 Mar 1995 02:32:47 GMT
      From: Johan.Dahl@ling.lu.se (Johan Dahl)

      This may be a stupid question but shouldn't this program work. I have
      looked thru the DIRM and I cant find any place that says something about
      dispatching on local methods.

      I have tested this small and VERY useful program on both Mindy and Marlais
      and both seems to ignore or rather write over the first method is defined.
      So I get error messages like "Argument error..."

      define method foo(a)
	 local method fum(b == #f)
	    0;
	 end method;

	 local method fum(b :: <integer>)
	    b * 2;
	 end method;

	 fum(a);
      end method;

      I wonder if this is a limitation in the implementations or not allowed in
      the language.

   'local method' does just that -- defines a local _method_.  When you
   call 'fum(a)', you are calling the method directly, not a generic
   function.

   This is the third time in the past 5 days someone has run into this,
   and asked the same question.  I think I know _why_ Dylan creates a
   local method (and I agree with my invented reason), but nonetheless, I
   think we need to think of a way to clarify this confusing point for
   people.

Perhaps one of the reasons for this confusion is that examples of
local methods are often shown with argument specializations/type
declarations.  Such examples may be more familiar and comforting to
those whose only previous experience is in statically typed languages,
but leave many others wondering why a local method is specializing its
arguments:

- Documentation?  Even if you believe in type declarations as a means
of documentation, a local method has much less need of this due to its
highly localized scope.

- Efficiency?  I would hope that a Dylan compiler can do a much better
job of optimization on a local method, again due to its pre-known
usage, whether or not argument specializations are present.

- Merely to increase the reading comfort level of static typers?  If
so, I see this as a disturbing trend: encouraging a style of
unnecessary type-specificity (and, ultimately, decreased flexibility
and productivity) in Dylan libraries and literature.
--
        Lawrence G. Mayka
        AT&T Bell Laboratories
        lgm@ieain.att.com

Standard disclaimer.
