shikantaza / pLisp

Don't Lisp, Talk!
GNU General Public License v3.0
58 stars 4 forks source link

VALUES is really just LIST #33

Open heegaiximephoomeeghahyaiseekh opened 8 years ago

heegaiximephoomeeghahyaiseekh commented 8 years ago

While being similar to lists, multiple return values in Lisp are supposed to be a separate type that allows you to implicitly ignore the additional values. For example, you should be able to do this:

(car (values '(1 2) '(3 4))) => 1

In my (unpublished) interpreter, I handle this by implementing a special type, TUPLE, which is produced only by VALUES. The TUPLE type can be just a list or vector with a different type tag.

Whenever a TUPLE passes to anything other than MULTIPLE-VALUE-LIST, it should be converted to the first value in the tuple. Other multiple-value forms, such as MULTIPLE-VALUE-BIND and MULTIPLE-VALUE-CALL, can be implemented as macros.

The REPL should capture multiple values and print each one on a separate line.

Also, the continuation captured by call-cc should accept any number of arguments instead of just one argument. The effect of calling it with multiple arguments should be the same as if the continuation returned using VALUES.

shikantaza commented 8 years ago

I'm somewhat ambivalent about this, this would involve adding a new object type as you mentioned, and may need extensive changes. I'll investigate this further. Deviating from Lisp canon seems to be the easier option here :-)

j3pic commented 5 years ago

Maybe just removing VALUES would be the thing to do here. Why have something with that name if the concept is not actually supported?

shikantaza commented 5 years ago

Yeah, it's an artifact of an earlier thought process. I'm still trying to remain as close as possible to Common Lisp though, will investigate what it takes to implement VALUES faithfully; will remove it if not feasible given pLisp's object model.

Regards, Rajesh

On Sun 7 Jul, 2019, 7:41 AM j3pic, notifications@github.com wrote:

Maybe just removing VALUES would be the thing to do here. Why have something with that name if the concept is not actually supported?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shikantaza/pLisp/issues/33?email_source=notifications&email_token=AAHBZ7SVRUXNXGHEMR5Z75LP6FGF3A5CNFSM4CBE5ZDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLDJLA#issuecomment-508966060, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHBZ7V2SMFYQOL5CYZBICDP6FGF3ANCNFSM4CBE5ZDA .