Comments (1)
The BH Language Manual mentions the keyword where
as used in the package
, class
, and instance
syntax, but does not describe any other usage. I don't know if this omission is intentional or not.
I do see that the BSC parser accepts where
in expressions. That is, anywhere that an expression is expected, you can write e where ...
-- however, this is only for certain e
. Specifically, e
has to be a simple expression, like a variable, constructor, tuple, literal, etc, and it can optionally have field selection or bit extraction. It turns out that (e)
is considered a tuple of 1 element, so your example can be made to compile by putting the expression in parentheses:
prioEnc i = (f i[2:2] i[1:1] i[0:0])
where
Of course, you can also use a let
-statement instead of where
:
prioEnc i =
let f = ...
in f i[2:2] i[1:1] i[0:0]
These two forms are equivalent, because the where
is part of the expression, and not part of the declaration of prioEnc
.
You could also get it to compile by using a simpler expression preceding the where
keyword:
prioEnc i = res
where
res = f i[2:2] i[1:1] i[0:0]
f = ...
I assume that you attempted to use where
because you are familiar with Haskell? In Haskell, the where
keyword is supported as part of the RHS (right hand side) of a declaration. So in Haskell, the where
would be part of the syntax for declaring prioEnc
; but that's not what BSC supports.
Where do we go from here? I guess there are four options:
- Remove the parser support for expression
where
so that BSC matches the documentation. (This is probably not what we want to do.) - Leave the BH parser as it is, but document its current behavior in the language manual.
- Expand the current
where
expression syntax, so that it can apply to any expression (not just simple expressions) -- which would allow your example to compile -- and of course document it in the language manual. - Change BSC to support
where
as a declaration RHS syntax and not as an expression syntax, to match what Haskell supports -- which would also allow your example to compiled -- and of course document it in the language manual.
I'm not sure which is preferable. Maybe @rsnikhil and @mieszko can weigh in.
from bsc.
Related Issues (20)
- Unresolved numeric contexts that should be resolvable HOT 6
- Verilog import fails in macro substitution HOT 2
- expandPorts.tcl has hardcoded paths which do not exist. HOT 1
- Unexpected behavior in Stmt sequence when using par HOT 2
- Bluesim divide-by-zero behavior is inconsistent on arm64 HOT 2
- Type synonyms with phantom parameters can lead to strange behaviors (E.g., compiler hang) HOT 4
- doc example for mkUniqueWrapper2 HOT 7
- -remove-unused-modules flag doesn't work with mkProbe module provided in std library HOT 2
- Failures with compilation on raspberry-pi 5 HOT 4
- GCC 14 emits extra warnings HOT 1
- Github's macos-11 runner is going away HOT 1
- [Bluesim] Simulation executable fails with `undefined symbol: _Z21vcd_write_scope_startP9tSimStatePKc` HOT 9
- `sqrtFP` is incorrect HOT 6
- compile to verilog, convert function to function, but not to modules. HOT 1
- Preserving structure at synthesis boundaries HOT 2
- Better control of wrapper generation HOT 6
- Incremental compilation model and UX improvements
- how does bsc disambiguate between V2K keywords and library functions? HOT 2
- Debugging with Bluetcl - displaying values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bsc.