bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is '&&&'? How does it differ from '&&am

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
nikhil
Site Admin


Joined: 23 Jul 2007
Posts: 14
Location: Waltham, MA

PostPosted: Fri Jul 25, 2014 3:22 pm    Post subject: What is '&&&'? How does it differ from '&&am Reply with quote

'&&&' is used in a pattern-matching context, where it has both the '&&' functionality and a name-binding/scoping functionality.

For example:

Code:

1    if (mx matches tagged Valid .x
2        &&&
3        foo (x) matches tagged Exception .e)
4       begin
5          ...
6       end
7    else
8       begin
9          ...
10      end


In line (1), if the pattern-match succeeds, then the variable 'x' is bound to the corresponding contained value in the Maybe value mx. This 'x' is visible and used on line 3 (argument to foo). Further, if the pattern-match on line 3 succeeds, then it binds the variable 'e' to the corresponding contents of the Exception, and then both variables 'x' and 'e' are bound and visible and usable in the 'then' part of the conditional (line 5).

If either pattern-match fails and we execute the 'else' part, then neither 'x' nor 'e' is visible (line 9).

Thus, you can see that '&&&'
- is a conjunction, just like '&&'
- but also carries name-bindings from a pattern on its left to the context on its right.

Because it has this syntactic role, and is not merely a pure operator like '&&', it is only legal at the top-level of a conditional expression, never nested inside other expressions.

[I've shown an 'if' statement, but this notation is also available in
rule conditions, case statements, while statements, etc. ]
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP