Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-02-10
21:15 • Closed ticket [3483088fff]: tailcall next doesn't work ... should it? ... artifact: ca65eefcd6 user: dkf
2012-02-02
14:32 • Ticket [3483088fff]: 4 changes artifact: 4995d20128 user: coldstore
14:13 • Add attachment tailcall.tcl to ticket [3483088fff] artifact: fae61a2ff6 user: coldstore
14:13 • Ticket [3483088fff] tailcall next doesn't work ... should it? status s... artifact: 3e2933222c user: coldstore
14:13 • Ticket [3483088fff]: 4 changes artifact: 0fab140b38 user: coldstore
14:13 • Ticket [3483088fff]: 4 changes artifact: cd98922dc5 user: coldstore
14:12 • Ticket [3483088fff]: 4 changes artifact: 4dcc9efb2c user: coldstore
13:58 • Ticket [3483088fff]: 4 changes artifact: 1d793c346a user: coldstore
06:58 • New ticket [3483088fff]. artifact: a0e22dffbf user: coldstore

[tailcall next] doesn't work ... should it?

Closed / Works For Me3483088fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2012-02-02 06:58:57
[tailcall next] complains spuriously that 'next may only be called from inside a method' even when it is.  See attached.

I think I have another problem related to this, where [tailcall next] is complaining spuriously 'wrong # args: should be "next"', but will see how this one pans out.
coldstoreplain2012-02-02 13:58:58
File Added - 434661: tailcall.tcl
coldstoreplain2012-02-02 14:12:57
File Added - 434663: tailcall.tcl
coldstoreplain2012-02-02 14:13:13
File Deleted - 434663:
coldstoreplain2012-02-02 14:13:41
File Deleted - 434661:
coldstoreplain2012-02-02 14:13:57
File Added - 434664: tailcall.tcl
coldstoreplain2012-02-02 14:32:55
I guess, by the time the [next] is called, the [tailcall] has already taken effect, and somehow the context is no longer that of an object.  Shouldn't it be, though?
dkfplain2012-02-10 21:15:25
allow_comments - 1

[tailcall foo] is like [return [uplevel foo]] apart from some quoting issues and the context in which [foo] is resolved. (But there's only one [next], so the resolution will be consistent.) Thus, [tailcall next] only works at all when the _caller_ of the object can do a [next], which means that it needs to be done inside a method called from inside a method. I'm guessing that that's something you don't need. :-) It's complaining about the wrong # args because that's what the caller's next method implementation wants (I guess).

So... it works, but not in the way you would reasonably want. (Remember, [next] effectively does an [uplevel] inside itself so methods don't need to know about potential subclasses overriding them. It also _requires_ that the caller be an object method body context, since it uses that to know what is going on.) To do anything else would require teaching [tailcall] to know specially about [next] and vice versa, which would be rather disgustingly nasty.
Log in (anonymous is fine) to add a comment.

Attachments: