-
Notifications
You must be signed in to change notification settings - Fork 5
/
rpc.edh
60 lines (39 loc) · 1.12 KB
/
rpc.edh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# here the language constructs for RPC support is demostrated,
# for actual working examples of RPC over the network, checkout
# the [nedh](https://github.com/e-wrks/nedh) project and its tour.
{
# mockup some remote site environment
method evalRemotely ( xpr ) {
mockupEnv = scope() # use the scope of this proc
# emulate procedures available at a remote site
method callThePolice ( telno ) {
console.warn<| 'Alerts ringing #tel ' ++ telno ++ ' ...'
}
# simulate remote exec
mockupEnv.eval( xpr )
}
}
{
# MWE of some lib/framework
# unique tag class for countries
class Country { __repr__ = 'Country()' }
# some known countries
CN := Country()
US := Country()
JP := Country()
# lookup the emergency call number for a country
method emergCallNumOf( c ) case c of {
CN -> 110
US -> 911
JP -> 999
error( "I don't know your country: " ++ c )
}
}
{
# MWE of some app snippet
currentCountry = CN
rpc = expr callThePolice( telno = {$ emergCallNumOf( currentCountry ) $} )
console.info<| 'Remote procedure call:\n ' ++ rpc
evalRemotely( rpc )
}
quit