From -9215271152564552993 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,5be30c38f618a07b X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2002-06-03 10:05:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: Francis Glassborow Newsgroups: comp.std.c++ Subject: Re: Why switch w/ only integral types? Date: Mon, 3 Jun 2002 17:04:43 GMT Organization: Southfield Microcomputer SS Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: References: <6ee7d287.0203202005.63e0b7b3@posting.google.com> <3CCE6310.672E55DF@webmaster.com> <23b84d65.0205291735.208a70d6@posting.google.com> Reply-To: Francis Glassborow X-Trace: mail2news.demon.co.uk 1023123889 mail2news:27106 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) MIME-Version: 1.0 Content-Type: text/plain;charset=us-ascii User-Agent: Turnpike/6.01-U () Lines: 44 Xref: archiver1.google.com comp.std.c++:11808 In article , Grzegorz Jakacki writes >remove.haberg@matematik.su.se (Hans Aberg) wrote in message news:... >> Check Haskell http://haskell.org. I recall that in Haskell (like in SML >> and some other functional languages), one can define functions by patterns > >Pattern matching in Haskell is based on the fact, that every value >contains information on which "constructor" has created it. E.g. >values of list type have two constructors: nilary constructor [] and >binary constructor `:`, and looking at list value runtime can tell, >which constructor has been used to create it. The constructors are >used to form patterns. In C++ the values have no unique >"constructions". I am not familiar enough with Haskell to understand the significance of this. However it is perfectly possible for C++ objects to track which ctor has been used to construct them: class X { enum ctor{ default_ctor, copy_ctor, type1_ctor ...}; ctor const which; ... public: X():which(default_ctor)...{...} X(X const &):which(copy_ctor)...{...} .... }; And, of course, you must provide an assignment operator. -- Francis Glassborow ACCU 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]