Arc Forumnew | comments | leaders | submitlogin
1 point by stefano 5945 days ago | link | parent

It could return the list (1 2), but this would mean to cons up a new list every time we use 'pr just to throw it away. Multiple return values would solve the problem. Why not add them to the language?


1 point by bOR_ 5945 days ago | link

at least in agent-based models, printing is not the thing that is happening so often that consing up a new list is prohibitive.

How much more expensive is cons compared to multiple return values? I remember there being a long discussion against mrvs.

-----

2 points by stefano 5944 days ago | link

> How much more expensive is cons compared to multiple return values?

It depends on the GC used and on the implementation. mrvs are usually pushed on the stack, so there is no GC overhead. When I develop applications with Lisp, I notice that most of the time reducing the amount of garbage speeds up the program noticeably. It's not only a problem of consing, it's also a problem of collecting the garbage. More garabage, more collection cycles.

-----

1 point by xrchz 5934 days ago | link

do pr or prn create a string? it might be less expensive to return that string if it is created

-----