aqua/aqua-src/ret.aqua

32 lines
767 B
Plaintext
Raw Normal View History

2021-08-21 08:10:38 +00:00
module Ret
import Service from "service.aqua"
use "error.aqua"
2021-09-07 08:09:48 +00:00
export GetStr, multiReturnFunc, Service as S
2021-08-21 08:10:38 +00:00
2021-08-11 07:55:25 +00:00
service GetStr("multiret-test"):
retStr: string -> string
2021-08-11 07:55:25 +00:00
service GetNum("multiret-num"):
retNum: -> u8
2021-09-07 08:09:48 +00:00
const SOME_NUM = 5
const SOME_STR = "some-str"
2021-08-11 07:55:25 +00:00
func tupleFunc() -> string, u8:
2021-09-07 08:09:48 +00:00
str <- GetStr.retStr(SOME_STR)
2021-08-11 07:55:25 +00:00
n <- GetNum.retNum()
2021-08-21 08:10:38 +00:00
Err.Peer.is_connected("Connected?")
2021-08-11 07:55:25 +00:00
<- str, n
func multiReturnFunc(somethingToReturn: []u8, smthOption: ?string) -> []string, u8, string, []u8, ?string, u8:
res: *string
2021-09-07 08:09:48 +00:00
res <- GetStr.retStr(SOME_STR)
try:
res <- GetStr.retStr("random-str")
catch e:
GetStr.retStr(e.msg)
2021-08-11 07:55:25 +00:00
res, tNum <- tupleFunc()
2021-09-07 08:09:48 +00:00
<- res, 5, SOME_STR, somethingToReturn, smthOption, tNum