bpadalino / vhdl-format Goto Github PK
View Code? Open in Web Editor NEWVHDL String Formatting Library
License: The Unlicense
VHDL String Formatting Library
License: The Unlicense
Does the string_list
have to be public? If it is not intended to be used by the user, then it probably should be hidden within package body.
Formatting strings with single argument is probably the most common case.
Currently using f
function with single argument is relatively complex.
Trying
write(output, f("int: {d}", f(10)));
And it causes:
fmt_test.vhd:480:24:error: can't resolve overload for function call, slice or indexed name
write(output, f("int: {d}", f(10)));
^
fmt_test.vhd:480:24:error: possible interpretations are:
fmt.vhd:106:14:error: function f [std_logic_vector, string return string]
fmt.vhd:99:14:error: function f [string, string return string]
fmt.vhd:74:14:error: function f [string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string return string]
fmt_test.vhd:480:14:error: cannot resolve overloading for subprogram call
write(output, f("int: {d}", f(10)));
^
ghdl:error: compilation error
The compiler is right as the f function is overloaded.
I have to explicitly cal fpr
:
write(output, fpr("int: {d}", f(10)));
I wonder how this can be solved.
My current idea is to provide more overloading for f
with 2 parameters, the fmt string and a basic type.
This would allow to call:
write(output, f("int: {d}", 10));
The compiler currently says:
fmt_test.vhd:480:24:error: no overloaded function found matching 'f'
write(output, f("int: {d}", 10));
^
ghdl:error: compilation error
what means that the new functions will not introduce new overload conflicts.
The implementation is trivial:
function f(s : string; i : integer) return string is begin return fpr(s, f(i)); end function;
FNAME
is actually not a filename but file path, and probably should be renamed to FILEPATH
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.