Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hai prog: multiple return values

Name: Anonymous 2009-10-02 19:31

Hello

I know one can use pass-by-reference for getting multiple values back from a function, but is there a language that allows you to actually define multiple outputs seperate from the parameter list for super neatness.

I was thinking it would be super-cool to have an auto-defined struct based on the function return values. so in some pseudo-language it would be like...


def splitstring  string<s char<sep string>a string>b

s = "hello world"

splitstring s ' '

printf(splitstring.a)
printf(splitstring.b)


would that be totally kawaii aewsome?

obviously each thread would have its only instances of these auto-structs.

Name: Anonymous 2009-10-03 0:12

>>18
Yes, you can emulate multiple return values using various conventions, but there's huge usability differences between C's out parameters, or returning a pointer to an array/structure/list and Lisp's multiple return values. The first is just a natural consequence of how pointers work, and this allows you to basically get that functionality, while the second is a well-supported part of the language which leads to completly different idioms in writing code. I could explain how this works in detail, but it's best to just see for yourself.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List