aqua/aqua-src/ret.aqua
2021-09-07 11:09:48 +03:00

32 lines
767 B
Plaintext

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