type safety (was Re: FAQ terminology harmonisation)

Chris Pressey cpressey@REDACTED
Fri Apr 4 17:27:58 CEST 2003


On Fri, 04 Apr 2003 08:03:49 +0100
Peter-Henry Mander <erlang@REDACTED> wrote:

> Hmm... This emphasis on exact matching on type would potentially break
> 
> an aspect of Erlang I have learnt to appreciate: pattern matching. I
> can make a function match exactly or match with increasing degrees of 
> generality. A special case function first, followed by general case.
> If none match, an exception occurs. I can work with a bit of dicipline
> and tag my tuples, and enforce that functions only acccept tagged
> tuples.
> 
> Pete.

Do you mean you write functions like this?

  case Value of
    Tuple when is_tuple(Tuple) ->
      case Tuple of
        Record when is_record(Record, my_record) ->
          do_stuff(Record)
      end
  end

That seems silly.  You probably mean like this:

  case Value of
    Record when is_record(Record, my_record) ->
      do_stuff(Record);
    Tuple when is_tuple(Tuple) ->
      do_other_stuff(Tuple)
  end

But if records were opaque, that sort of match wouldn't break, either.

-Chris




More information about the erlang-questions mailing list