Skip to content

Commit 80ca84a

Browse files
Fix typos in Getting Started
Co-authored-by: Maria Scott <maria-12648430@hnc-agency.org>
1 parent 6189ca0 commit 80ca84a

4 files changed

Lines changed: 111 additions & 112 deletions

File tree

system/doc/getting_started/conc_prog.md

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ done
7171
```
7272

7373
As shown, the function `say_something` writes its first argument the number of
74-
times specified by second argument. The function `start` starts two Erlang
74+
times specified by the second argument. The function `start` starts two Erlang
7575
processes, one that writes "hello" three times and one that writes "goodbye"
7676
three times. Both processes use the function `say_something`. Notice that a
7777
function used in this way by `spawn`, to start a process, must be exported from
@@ -149,7 +149,7 @@ start() ->
149149
```erlang
150150
1> c(tut15).
151151
{ok,tut15}
152-
2> tut15: start().
152+
2> tut15:start().
153153
<0.36.0>
154154
Pong received ping
155155
Ping received pong
@@ -205,7 +205,7 @@ receive
205205
pattern2 ->
206206
actions2;
207207
....
208-
patternN
208+
patternN ->
209209
actionsN
210210
end.
211211
```
@@ -254,7 +254,7 @@ process "ping":
254254
Ping_PID ! pong
255255
```
256256

257-
Notice how the operator "\!" is used to send messages. The syntax of "\!" is:
257+
Notice how the operator `!` is used to send messages. The syntax of `!` is:
258258

259259
```erlang
260260
Pid ! Message
@@ -283,7 +283,7 @@ Pong_PID ! {ping, self()},
283283
```
284284

285285
`self/0` returns the pid of the process that executes `self/0`, in this case the
286-
pid of "ping". (Recall the code for "pong", this lands up in the variable
286+
pid of "ping". (Recall the code for "pong", this ends up in the variable
287287
`Ping_PID` in the `receive` previously explained.)
288288

289289
"Ping" now waits for a reply from "pong":
@@ -397,7 +397,7 @@ pong ! {ping, self()},
397397
## Distributed Programming
398398
399399
Let us rewrite the ping pong program with "ping" and "pong" on different
400-
computers. First a few things are needed to set up to get this to work. The
400+
computers. First a few things need to be set up to get this to work. The
401401
distributed Erlang implementation provides a very basic authentication mechanism
402402
to prevent unintentional access to an Erlang system on another computer. Erlang
403403
systems which talk to each other must have the same _magic cookie_. The easiest
@@ -438,7 +438,7 @@ Erlang system running on a computer is called an _Erlang node_.
438438
439439
(Note: `erl -sname` assumes that all nodes are in the same IP domain and we can
440440
use only the first component of the IP address, if we want to use nodes in
441-
different domains we use `-name` instead, but then all IP address must be given
441+
different domains we use `-name` instead, but then all IP addresses must be given
442442
in full.)
443443
444444
Here is the ping pong example modified to run on two separate nodes:
@@ -483,20 +483,20 @@ started on kosken, called ping, and then a node on gollum, called pong.
483483
On kosken (on a Linux/UNIX system):
484484
485485
```text
486-
kosken> erl -sname ping
487-
Erlang (BEAM) emulator version 5.2.3.7 [hipe] [threads:0]
486+
kosken$ erl -sname ping
487+
Erlang/OTP 28 [erts-16.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
488488
489-
Eshell V5.2.3.7 (abort with ^G)
489+
Eshell V16.3 (press Ctrl+G to abort, type help(). for help)
490490
(ping@kosken)1>
491491
```
492492
493493
On gollum:
494494
495495
```text
496-
gollum> erl -sname pong
497-
Erlang (BEAM) emulator version 5.2.3.7 [hipe] [threads:0]
496+
gollum$ erl -sname pong
497+
Erlang/OTP 28 [erts-16.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
498498
499-
Eshell V5.2.3.7 (abort with ^G)
499+
Eshell V16.3 (press Ctrl+G to abort, type help(). for help)
500500
(pong@gollum)1>
501501
```
502502
@@ -533,7 +533,7 @@ Pong finished
533533
534534
Looking at the `tut17` code, you see that the `pong` function itself is
535535
unchanged, the following lines work in the same way irrespective of on which
536-
node the "ping" process is executes:
536+
node the "ping" process is executed:
537537
538538
```erlang
539539
{ping, Ping_PID} ->
@@ -623,7 +623,7 @@ Before starting, notice the following:
623623
- This example only shows the message passing logic - no attempt has been made
624624
to provide a nice graphical user interface, although this can also be done in
625625
Erlang.
626-
- This sort of problem can be solved easier by use of the facilities in OTP,
626+
- This sort of problem can be solved more easily by using the facilities in OTP,
627627
which also provide methods for updating code on the fly and so on (see
628628
[OTP Design Principles](`e:system:design_principles.md`)).
629629
- The first program contains some inadequacies regarding handling of nodes which
@@ -666,9 +666,6 @@ File `messenger.erl`:
666666
%%% Reply {messenger, logged_on} logon was successful
667667
%%%
668668
%%% To server: {ClientPid, logoff}
669-
%%% Reply: {messenger, logged_off}
670-
%%%
671-
%%% To server: {ClientPid, logoff}
672669
%%% Reply: no reply
673670
%%%
674671
%%% To server: {ClientPid, message_to, ToName, Message} send a message
@@ -697,7 +694,7 @@ server_node() ->
697694
messenger@super.
698695
699696
%%% This is the server process for the "messenger"
700-
%%% the user list has the format [{ClientPid1, Name1},{ClientPid22, Name2},...]
697+
%%% the user list has the format [{ClientPid1, Name1},{ClientPid2, Name2},...]
701698
server(User_List) ->
702699
receive
703700
{From, logon, Name} ->
@@ -734,22 +731,22 @@ server_logoff(From, User_List) ->
734731
lists:keydelete(From, 1, User_List).
735732
736733
737-
%%% Server transfers a message between user
734+
%%% Server transfers a message between users
738735
server_transfer(From, To, Message, User_List) ->
739736
%% check that the user is logged on and who he is
740-
case lists:keysearch(From, 1, User_List) of
737+
case lists:keyfind(From, 1, User_List) of
741738
false ->
742739
From ! {messenger, stop, you_are_not_logged_on};
743-
{value, {From, Name}} ->
740+
{From, Name} ->
744741
server_transfer(From, Name, To, Message, User_List)
745742
end.
746743
%%% If the user exists, send the message
747744
server_transfer(From, Name, To, Message, User_List) ->
748745
%% Find the receiver and send the message
749-
case lists:keysearch(To, 2, User_List) of
746+
case lists:keyfind(To, 2, User_List) of
750747
false ->
751748
From ! {messenger, receiver_not_found};
752-
{value, {ToPid, To}} ->
749+
{ToPid, To} ->
753750
ToPid ! {message_from, Name, Message},
754751
From ! {messenger, sent}
755752
end.
@@ -894,7 +891,7 @@ call. This would result in the process getting bigger and bigger for every loop.
894891
895892
Functions in the `lists` module are used. This is a very useful module and a
896893
study of the manual page is recommended (`erl -man lists`).
897-
`lists:keymember(Key,Position,Lists)` looks through a list of tuples and looks
894+
`lists:keymember(Key,Position,List)` looks through a list of tuples and looks
898895
at `Position` in each tuple to see if it is the same as `Key`. The first element
899896
is position 1. If it finds a tuple where the element at `Position` is the same
900897
as `Key`, it returns `true`, otherwise `false`.
@@ -914,8 +911,8 @@ any) and returns the remaining list:
914911
[{x,y,z},{b,b,b},{q,r,s}]
915912
```
916913
917-
`lists:keysearch` is like `lists:keymember`, but it returns
918-
`{value,Tuple_Found}` or the atom `false`.
914+
`lists:keyfind` is like `lists:keymember`, but it returns
915+
`Tuple_Found` or the atom `false`.
919916
920917
There are many very useful functions in the `lists` module.
921918
@@ -974,19 +971,19 @@ server_transfer(From, fred, "hello", User_List),
974971
This checks that the pid `From` is in the `User_List`:
975972
976973
```erlang
977-
lists:keysearch(From, 1, User_List)
974+
lists:keyfind(From, 1, User_List)
978975
```
979976
980-
If `keysearch` returns the atom `false`, some error has occurred and the server
977+
If `keyfind` returns the atom `false`, some error has occurred and the server
981978
sends back the message:
982979
983980
```erlang
984981
From ! {messenger, stop, you_are_not_logged_on}
985982
```
986983
987984
This is received by the client, which in turn does [`exit(normal)`](`exit/1`)
988-
and terminates. If `keysearch` returns `{value,{From,Name}}` it is certain that
989-
the user is logged on and that his name (peter) is in variable `Name`.
985+
and terminates. If `keyfind` returns `{From,Name}` it is certain that
986+
the user is logged on and that their name (peter) is in the variable `Name`.
990987
991988
Let us now call:
992989
@@ -995,11 +992,11 @@ server_transfer(From, peter, fred, "hello", User_List)
995992
```
996993
997994
Notice that as this is `server_transfer/5`, it is not the same as the previous
998-
function `server_transfer/4`. Another `keysearch` is done on `User_List` to find
995+
function `server_transfer/4`. Another `keyfind` is done on `User_List` to find
999996
the pid of the client corresponding to fred:
1000997
1001998
```erlang
1002-
lists:keysearch(fred, 2, User_List)
999+
lists:keyfind(fred, 2, User_List)
10031000
```
10041001
10051002
This time argument 2 is used, which is the second element in the tuple. If this
@@ -1012,10 +1009,10 @@ From ! {messenger, receiver_not_found};
10121009
10131010
This is received by the client.
10141011
1015-
If `keysearch` returns:
1012+
If `keyfind` returns:
10161013
10171014
```erlang
1018-
{value, {ToPid, fred}}
1015+
{ToPid, fred}
10191016
```
10201017
10211018
The following message is sent to fred's client:

system/doc/getting_started/records_macros.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ introduced:
5959
%%% Configure the location of the server node,
6060
-define(server_node, messenger@super).
6161

62-
%%%----END FILE----
62+
%%%----END FILE-----
6363
```
6464

6565
```erlang
@@ -89,7 +89,7 @@ introduced:
8989
-record(message_to,{to_name, message}).
9090
%%% logoff
9191

92-
%%%----END FILE----
92+
%%%----END FILE-----
9393
```
9494

9595
```erlang
@@ -135,7 +135,7 @@ message(ToName, Message) ->
135135
ok
136136
end.
137137

138-
%%%----END FILE----
138+
%%%----END FILE-----
139139
```
140140

141141
```erlang
@@ -178,7 +178,7 @@ await_result() ->
178178
exit(timeout)
179179
end.
180180

181-
%%%----END FILE---
181+
%%%----END FILE----
182182
```
183183

184184
```erlang
@@ -194,7 +194,7 @@ server() ->
194194
process_flag(trap_exit, true),
195195
server([]).
196196

197-
%%% the user list has the format [{ClientPid1, Name1},{ClientPid22, Name2},...]
197+
%%% the user list has the format [{ClientPid1, Name1},{ClientPid2, Name2},...]
198198
server(User_List) ->
199199
io:format("User list = ~p~n", [User_List]),
200200
receive
@@ -230,27 +230,27 @@ server_logon(From, Name, User_List) ->
230230
server_logoff(From, User_List) ->
231231
lists:keydelete(From, 1, User_List).
232232

233-
%%% Server transfers a message between user
233+
%%% Server transfers a message between users
234234
server_transfer(From, To, Message, User_List) ->
235235
%% check that the user is logged on and who he is
236-
case lists:keysearch(From, 1, User_List) of
236+
case lists:keyfind(From, 1, User_List) of
237237
false ->
238238
From ! #abort_client{message=you_are_not_logged_on};
239-
{value, {_, Name}} ->
239+
{_, Name} ->
240240
server_transfer(From, Name, To, Message, User_List)
241241
end.
242242
%%% If the user exists, send the message
243243
server_transfer(From, Name, To, Message, User_List) ->
244244
%% Find the receiver and send the message
245-
case lists:keysearch(To, 2, User_List) of
245+
case lists:keyfind(To, 2, User_List) of
246246
false ->
247247
From ! #server_reply{message=receiver_not_found};
248-
{value, {ToPid, To}} ->
248+
{ToPid, To} ->
249249
ToPid ! #message_from{from_name=Name, message=Message},
250250
From ! #server_reply{message=sent}
251251
end.
252252

253-
%%%----END FILE---
253+
%%%----END FILE----
254254
```
255255

256256
## Header Files
@@ -269,7 +269,7 @@ for example:
269269
```
270270

271271
In the case above the file is fetched from the same directory as all the other
272-
files in the messenger example. (_manual_).
272+
files in the messenger example. (_manual_)
273273

274274
.hrl files can contain any valid Erlang code but are most often used for record
275275
and macro definitions.
@@ -297,7 +297,7 @@ This is equivalent to:
297297
Creating a record is best illustrated by an example:
298298

299299
```erlang
300-
#message_to{message="hello", to_name=fred)
300+
#message_to{message="hello", to_name=fred}
301301
```
302302

303303
This creates:
@@ -306,8 +306,8 @@ This creates:
306306
{message_to, fred, "hello"}
307307
```
308308

309-
Notice that you do not have to worry about the order you assign values to the
310-
various parts of the records when you create it. The advantage of using records
309+
Notice that you do not have to worry about the order in which you assign values to the
310+
various parts of a record when you create it. The advantage of using records
311311
is that by placing their definitions in header files you can conveniently define
312312
interfaces that are easy to change. For example, if you want to add a new field
313313
to the record, you only have to change the code where the new field is used and
@@ -358,7 +358,7 @@ This is a standard macro (that is, defined by the system, not by the user).
358358
of using macros with, for example, [parameters](macros.md#defining-and-using-macros).
359359

360360
The three Erlang (`.erl`) files in the messenger example are individually
361-
compiled into object code file (`.beam`). The Erlang system loads and links
361+
compiled into object code files (`.beam`). The Erlang system loads and links
362362
these files into the system when they are referred to during execution of the
363363
code. In this case, they are simply put in our current working directory (that
364364
is, the place you have done "cd" to). There are ways of putting the `.beam`

0 commit comments

Comments
 (0)