Arc Forumnew | comments | leaders | submitlogin
Bug converting a procedure to string
3 points by talkdostop 6393 days ago | 3 comments

  > (type (coerce 3 'string))
  string

  > (type (coerce + 'string))
  fn
I think coercing a procedure to string should return a string representation.


2 points by ryantmulligan 6393 days ago | link

There are some issues with converting procedures to strings. Procedures that are closures can contain references to the environment. Then if you put an (eval) in there that makes it impossible without carrying around the entire lexical environment in the string of the procedure.

-----

1 point by kens 6393 days ago | link

According to the spec :-), coerce returns unchanged anything that is not tagged, char, integer, number, string, pair, nil, or symbol:

  arc> (coerce (table) 'potato)
  #hash()
Except for arguments of unexpected types (e.g. thread); then coerce fails.

-----

2 points by almkglor 6393 days ago | link

A neat idea - we just have to keep, say, the list containing the function definition attached with the function object.

-----