[nem-pl] Re: [nem-bug] [Nemerle 0000101]: warning message for giving the same name to two different def's should be changed

Michal Moskal malekith at pld-linux.org
Tue Mar 16 09:37:16 CET 2004


On Tue, Mar 16, 2004 at 08:43:55AM +0100, "Paweł W. Olszta" wrote:
> feedback at nemerle.org wrote:
> 
> >----------------------------------------------------------------------
> > awasylkowski - 03-16-2004 08:12 CET 
> >----------------------------------------------------------------------
> >I have been aware of a fact, that redefining values in functional
> >programming is common. I was just thinking changing the warning message
> >would make things more clear for people moving from C#, for instance.
> >Nemerle is supposed to be a better substitute for C#, and I remember us
> >changing its syntax almost every tuesday to be more C#-like; that's why I
> >opt for changing warning message.
> 
> Ja przepraszam, że na devel-pl, ale inaczej nie mogę.
> 
> Wydaje mi się, że przy mutable powinny być błędy, a przy def -- 
> warningi, które można wyłączyć (-Wdo-not-warn-on-redef czy coś w tym 
> guście) -- jeśli Kamil faktycznie by chciał redefiniować stałe.
> 
> Rationale: taki kod, w którym jest:
> 
> def x = ...;
> def x = ...;
> def x = ...;
> 
> f (x)
> 
> bardzo krzywo się czyta -- łatwo szukając definicji x w dużej funkcji 
> pogubić się i pominąć tą najwcześniejszą.

W poniższym:

	def x = foo ();
	def x1 = bar (x);
	def x2 = bar2 (x1);
	def x3 = baz (x2);
	f (x3)

znacznie łatwiej się pomylić niż w:

	def x = foo ();
	def x = bar (x);
	def x = bar2 (x);
	def x = baz (x);
	f (x)

Dodatkowo jak skasujemy linię z bar2 to wszystko ciągle jest ok.
Jak Kamil wspomniał to jest stdandardowa praktyka właśnie z tego powodu.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?




More information about the devel-pl mailing list