[Solved] Returning multiple values?

Is it possible in Sophia for a function to return multiple values, something like: return (a, b) in Solidity?

Sophia is a functional language and each function returns the result of the last statement, so yes you can “return” a tuple in Sophia:

  entrypoint foo(a : string, b : string) : string * string =
    (a, b)

would be a function that takes two arguments (strings in this case) and return a pair of strings.


thanks! could you give just a short example of how a calling function would work with that tuple? I can’t find in the documentation even how we get an element of a tuple…is it tuple[index] or tuple(index)…?

let (a, b) = t

There is also standard library functions to work with Pair’s and Triple’s

1 Like

Yeah, if you include Pair.aes you should have access to Pair.fst and Pair.snd functions. But the pattern matching in let should be a nicer option

1 Like

@hanssv.chain @philipp.chain actually let (a, b) = t compiles in IDE, like fireeditor, but when using remote compiler directly from js i get: Error: Http request for https://compiler.aepps.com/aci failed with status code 400. Status: Bad Request.
Error data: [{“message”:"Unexpected token ‘(’
Any ideas?

Trying https://compiler.aepps.com/version will reveal the problem I think… Ancient stuff.

1 Like

Ok, is there something more up to date? Why is the official remote compiler not up to date anyway?

IDE compiler (any idea what version is used there) and the official remote compiler are not the same version, I tried before syncing full node of course, but that took weeks and then got stuck at some point, there are no bootstrap files to speed up sync as far as i am aware of…I think it is really important for AE to make it easy for devs to dev aepps

who is in charge of maintaining https://compiler.aepps.com/

I think the latest compiler is at https://latest.compiler.aepps.com

The compiler development and info is at https://github.com/aeternity/aesophia and if you are interested in the HTTP-compiler in particular it is at https://github.com/aeternity/aesophia_http

docker pull aeternity/aesophia_http && docker run -p 3080:3080 aeternity/aesophia_http

give you the latest compiler locally.

1 Like

thanks, latest.compiler (4.3) works :slight_smile:
regarding the docker command, that works without sync? i assume aesophia_http connects to a remote full node, and then local compiler can work without waiting for sync?

1 Like

The compiler is separate from the node since a year and a half… Nothing to sync, I timed the command above it took 13 seconds to setup (on a fast internet)…