Erlang/OTP Forums

Author Message

<  Erlang  ~  Module(details)

shayan
Posted: Mon Jul 07, 2008 3:14 am Reply with quote
Joined: 06 Jul 2008 Posts: 2 Location: Göteborg,Sweden
Yes sure.i just started to learn Module and i just wanted to play around with it.so i wanted to write some function as below and as it stated in the book(Programming Erlang) page 34 chapter3(Sequential programming):
-module(geometry).
-export([area/1]).
area({rectangle,Width,Ht}) -> Width * Ht;
area({circle,R}) -> 3.14159 * R * R.

but whenever i just write the first line:
-module(geometry).
i get this error message:
** exception error: undefined function shell_default:module/1
So that, i can't continue with the rest and that is all about it.
View user's profile Send private message
michal
Posted: Mon Jul 07, 2008 1:19 pm Reply with quote
User Joined: 20 Jul 2006 Posts: 44 Location: London
You should save the source code of your module in a file geometry.erl and then compile it. On page 35 Joe explains how to compile your module. You cannot type the entire source of a module in Erlang shell, this is why you get error messages.

/Michal

_________________
http://www.erlang-consulting.com
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum