Skip Menu |

This queue is for tickets about the Syntax-Keyword-Try CPAN distribution.

Report information
The Basics
Id: 121267
Status: new
Priority: 0/
Queue: Syntax-Keyword-Try

Owner: Nobody in particular
Requestors: leonerd-cpan [...]

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)

Subject: TODO: value semantics
Download (untitled) / with headers
text/plain 939b
There's two parts to this feature - the syntax, and the implementation. Syntax-wise, I wonder if it would be nicer to keep the 'try' syntax purely for control flow, similar to things like 'if' and 'foreach', and add different looking syntax for value-returning semantics, so that the reader is less surprised by nonobvious behaviour. Perhaps the 'do' keyword could be used here as is used in other bits of perl syntax, e.g. my $value = do try { ... } catch { "default" }; my $value = try do { ... } catch { ... }; Implementation-wise, there are difficulties in propagating the runtime gimme context correctly into the body of the try block. Solving this one might require creating a new runtime op that can adjust the context dynamically. In particular, static analysis isn't good enough in such situations as 'do try' blocks being returned in tail position of a function sub { ...; return do try { foo() } } -- Paul Evans
Download (untitled) / with headers
text/plain 621b
Version 0.09_001 contains an experimental attempt at value semantics via the 'try do { ... }' syntax. It's a little buggy, in that local'isation of $@ fails for perls before 5.24. It *almost* makes do { try { ... } } happen to have value-returning semantics, except that to do that would break @ localisation and finally blocks for perls before 5.24 as well, so for now I haven't enabled that. If a solution to localisation and finally blocks on perls before 5.24 can be found, then maybe the do { try ... } notation will be considered "good enough" not to need this current hack of try do { ... } -- Paul Evans

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to