[erlang-questions] records in erlang and error while creating it

hemant gethemant@REDACTED
Mon Mar 5 15:11:58 CET 2007


On 3/5/07, Richard Carlsson <richardc@REDACTED> wrote:
> hemant wrote:
> > this might be a really stupid question, but at shell I am doing this:
> >
> > 2> -record(person, {
> > 2> firstName = "",
> > 2> lastName = "",
> > 2> age}).
>
> In the shell, you can only write expressions. You cannot write
> function definitions, such as 'f(X) -> X+1.', and you cannot
> write declarations (things like '-record(...).', which begin
> with a '-').
>
> What happened was that the shell thought you tried to write
> an expression that started with a unary minus, just as if
> you had written '- f(...)', and it interpreted the part where
> you said 'firstName = ""' literally and tried to match the
> atom 'firstName' against the empty string '""'. That's why the
> error message said 'badmatch'.
>
> You're certainly not the first person to make this kind of
> mistake. To write declarations and function definitions, you
> need to bring up your text editor and write a module.

Thanks a lot folks.

-- 
gnufied
-----------
There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.
http://people.inxsasia.com/~hemant



More information about the erlang-questions mailing list