❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayGautier's blog

HAC - recursive maze generator demo

28 May 2020 at 19:53
New example/demo, adapted from Rosetta Code's recursive maze generator.
HAC's Web site is here, source code is mirrored here.
Behind the scenes, the compiler was improved a little bit for displaying fixed-sized strings.

C:\Ada\hac\exm>..\hax -v2 maze_gen.adb

*******[ HAX ]******* Compiler version: 0.061 dated 28-May-2020.
*******[ HAX ]******* Caution: HAC is not a real Ada compiler. Type "hax" for license.
. . . .[ HAX ]. . . . Compiling from file: maze_gen.adb
. . . .[ HAX ]. . . . Compilation finished in 0.000414700 seconds.
. . . .[ HAX ]. . . . Starting p-code VM interpreter...
Height: 15, Width: 24
Starting generation at 7, 12
| | | | | |
+ +---+ +---+---+ + +---+ +---+ +---+---+ + + + + +---+---+---+---+---+ +
| | | | | | | | | | | | | | |
+---+ +---+ +---+ + +---+---+ + + +---+---+---+ + +---+---+ + +---+ +---+
| | | | | | | | | | | |
+ +---+ +---+---+---+ +---+ + + +---+---+---+ + +---+ +---+ + +---+---+ +
| | | | | | | | | | | | | | |
+ +---+ + + + + + + +---+---+ + + + +---+ +---+ +---+ +---+---+ +
| | | | | | | | | | | | | | | | | | |
+---+ + + + +---+ + + + + + + + +---+ +---+ + + + + +---+ +
| | | | | | | | | | | | | | | | |
+ +---+ +---+---+ + + +---+ + +---+ + + +---+ +---+---+ +---+ + +---+
| | | | | | X | | | | | | | | |
+ + +---+---+ +---+---+ + +---+---+ + + + + + +---+ +---+ +---+ + +
| | | | | | | | | | | | | | | | |
+ +---+ + +---+---+ +---+---+---+ +---+---+ +---+ +---+ +---+---+ + + + +
| | | | | | | | | |
+ + +---+ + +---+---+ +---+---+---+ + +---+ + +---+---+ +---+---+---+---+ +
| | | | | | | | | | | | | | |
+ + + + + + + + + + +---+ + + +---+---+---+ +---+---+---+---+ +---+
| | | | | | | | | | | | | |
+---+ + + +---+---+---+---+ +---+ +---+ + + + + +---+---+---+---+ +---+ +
| | | | | | | | | | | | |
+ +---+---+---+ +---+---+ +---+ + + +---+ +---+ +---+---+---+ +---+---+ + +
| | | | | | | | | | |
+ + +---+---+---+---+ +---+---+---+ +---+---+---+ + +---+---+---+---+ +---+---+ +
| | | | | | | | | | | | |
+ + + + + + + +---+ + +---+---+---+ + +---+---+---+ +---+ + +---+ +
| | | | | | | |
-------[ HAX ]------- VM interpreter done after 0.080759500 seconds.


HAC v.0.07 - Exceptions and trace-backs

1 June 2020 at 14:35
Since yesterday, errors are propagated by HAC, as expected, down the call stack.
You get by default a detailed trace-back, like the following one. HAC's output is:
  HAC VM: raised Constraint_Error
Out of range
Trace-back locations:
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 18
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF at line 27
exception_04.adb: Exception_04.Nest at line 34
exception_04.adb: Exception_04 at line 42
GNAT's output on the same program is:
  raised CONSTRAINT_ERROR : exception_04.adb:18 range check failed
Exception_04.Nest.Ntf.Add_N_Shift.Shift_N_Add at exception_04.adb:18
Exception_04.Nest.Ntf.Add_N_Shift at exception_04.adb:23
Exception_04.Nest.Ntf.Add_N_Shift.Shift_N_Add at exception_04.adb:16
Exception_04.Nest.Ntf.Add_N_Shift at exception_04.adb:23
Exception_04.Nest.Ntf.Add_N_Shift.Shift_N_Add at exception_04.adb:16
Exception_04.Nest.Ntf.Add_N_Shift at exception_04.adb:23
Exception_04.Nest.Ntf.Add_N_Shift.Shift_N_Add at exception_04.adb:16
Exception_04.Nest.Ntf.Add_N_Shift at exception_04.adb:23
Exception_04.Nest.Ntf.Add_N_Shift.Shift_N_Add at exception_04.adb:16
Exception_04.Nest.Ntf.Add_N_Shift at exception_04.adb:23
Exception_04.Nest.Ntf at exception_04.adb:27
Exception_04.Nest at exception_04.adb:34
Exception_04 at exception_04.adb:42
Main at b__exception_04.adb:294

You can look in the "test" directory at the files "exception_01.adb", "exception_02.adb", ... for playing with some examples.

HAC (HAC Ada Compiler) is available on two open-source development sites:


HAC is a small, quick, open-source Ada compiler, covering a subset of the Ada language.
Even though the HAC documentation is more or less non-existent, the good news is that you can use as a help Ada books and online documentation about Ada: HAC does not define a dialect of Ada, only a subset. A glimpse into the file "src/hac_pack.ads" gives you the currently available types and subprograms.


LEA 0.71 - exception trace-back

3 June 2020 at 18:31
Following the implementation of trace-backs in HAC, this feature is now included in the LEA editor.

Better showing an example. Suppose your Ada program has a bug that was not detected at compile-time (it happens sometimes), like an array index being out-of-range. In this case HAC will raise a Constraint_Error exception (as expected from any Ada system).

Once you have closed the message box about the unhandled exception, the message list will display the trace-back, that is the chain of all subprogram calls at the moment the error has happened. Here we have an example with recursive calls, and the error was planted for the moment where the parameter Level is 0.
For your comfort, you can click on a line of the trace-back and LEA will find the correct file and the correct line as well!

Here is a link to LEA: https://l-e-a.sourceforge.io/.
You can download a read-to-use Windows executable there.

The LEA sources are available on the above site as well as on GitHub: https://github.com/zertovitch/lea .

Furthermore, the sources for the HAC system are located at
    https://github.com/zertovitch/hac .


HAC v.0.072 - Subtype Indication

7 June 2020 at 19:44
One more step in our adventures in compiler construction...
Recently, we've moved the parsing of ranges to a new package, HAC.Parser.Ranges.
One chunk was about static ranges like "1 .. 5" for defining arrays.
The second chunk was the dynamic ranges in FOR loops (like in "for i in j + k .. l * 2 loop").
It was logical to put both pieces in the same package, especially since the Ada standard has a much more general definition: discrete_subtype_definition (RM 3.6 (6)).
Of course, with HAC, we don't try to implement the full standard or even the full dynamic aspects of a single syntactical element like discrete_subtype_definition, which allows constructs like this one:
    procedure SD3 is
for I in 1 .. 3 loop
type T1 is new Integer range 1 .. I * 5; -- I is dynamic
subtype T2 is T1 range 1 .. T1 (I);
type T3 is array (1 .. 2 * I) of T2;
type T4 is array (1 .. 3 * I) of T3;
B: T4;
end loop;

We prefer to add piece by piece features we find cool in Ada.
For instance, the subtype_indication (RM 3.2.2).
Again, something that sounds very bureaucratic, but what it represents is a very powerful shortcut:
Instead of writing
    x : array (False .. True) of Integer;

you can write in a nicer way:
    x : array (Boolean) of Integer;

same for loops:
    for b in Boolean loop
x (b) := ...
end loop;
As an illustration, here is an excerpt of the before/after comparison on one of the HAC examples:

Click to enlarge

New Fed Put Levels (Update: June 2020)

17 June 2020 at 11:57
In the 20th century, financial investment was a complex and serious topic.
You had to choose your mix of bonds of various maturities and risk levels - all associated with a very broad range of rates.
Similarly, you could build your mix of stocks (value vs. growth) or replicate more or less an index.
There was this thing called "free market". Good or bad - this is not the question. Perhaps it was just to show to the "Reds" that this notion of "free markets" was working so much better.

Now, things are much simpler. After a series of crises (dotcom, subprimes, Euro zone, and recently, the covid-19) the central banks have been more or less forced to set interest rates to zero or less, and frequently launch new programs for monetizing bonds and other financial assets. Governments take the opportunity of low interest rates and monetization not to balance their budget, but to increase their debts to the infinity. Same for corporations and even individuals. Zero rate = infinite leverage. Easy.

So, presently, all is simple. Bonds are a nonsensical business for investors - except those who are obliged to buy them, like insurances. Regarding stocks, old-school valuations like P/E ratios, or book value, or dividends, or credit rating of the underlying company, do not matter anymore: the Fed or the ECB will buy everything, even junk bonds. A funny consequence is that stock of bankrupt companies like Hertz are doing well, and the same Hertz is now selling new shares while under Chapter 11. Perhaps they will sell enough to balance their books, who knows!

Since the Fed's latest emergency plan a couple of days ago, we know what are the current approximate, implicit levels at which the Fed will do something more to support the financial markets.

Trade accordingly!
PS: The parts of the charts' data prior to 2020 was automatically digitized by the Recurve tool (part of the open-source Generic Image Decoder project in Ada).
PPS: here a "meme" about the subject:

LEA 0.74 - embedded Ada samples collection

27 June 2020 at 20:23
From now on, LEA has got the uber-gadget: a samples collection.
Are you looking for an example to start a script, or an algorithm, or some other inspiration?
The menu selection "Actions → Code sample" will offer you a choice of programs of various sizes.
Actually, they are examples from the HAC project (the HAC compiler is embedded in LEA).
You don't even need to fish those examples in the Internet: they are embedded within LEA as well.
In a few clicks, an example will pop in a LEA window and you can run it immediately.

LEA (Lightweight Editor for Ada) is a free, open-source software. It can be found here.

Feedback is appreciated.
Don't hesitate to sponsor the project with a small donation (from the link above: "Donate" link).


New menu entry: Code sample (click to enlarge image)

Sample selector (click to enlarge image)

Bullshit Generator: the Next Steps

1 July 2020 at 06:11
Here we admire again the recyclability of high-quality bullshit. The latest additions to the CBSG stem from an article written in 1996 - a time when the double-digit-growth boys were busy replacing boring industry by shiny finance. The article was found by bootstrapping (mark a sentence from the CBSG, search it with your preferred search engine). Some extracts are appealing:
Enron didn't rely on huge "bet-the-company" gambles to create growth. Each step was a manageable investment that built on established capabilities and offered the potential to add new ones.
A company need not possess strengths in all areas of a business—just in the areas important to making money. Growers distinguish between attributes that garner value and those that are simply necessary to play the game. Enron became a world leader in international private power generation because it saw that profit did not depend on construction and operation skills, but on deal structuring and risk allocation.
Anyway. Here are some new key additions to the CBSG, put in practice:

One thing about talent retention is clear: reputation and resiliency turbocharge a values-based market practice.
One thing about data practices is clear: delivery framework, competitive differentiator and solution boost architectures.

The Digital Marketers create strategic options and opportunities across geographies.
The pioneers create strategic options and opportunities going forward.

Opting out of reorganizations is not a choice, while the team players create new business options.
A profit-maximizing portfolio shaping 24/7 reenergizes a motivational onboarding solution. As a result, the team players create new business options.

Trending your numbers should carve a competitive position.
The point is not merely to carve a competitive position. The point is to reinvest in a high-grade footprint.

The team players preempt competitors by thinking outside of the box.
High-performance benchmarkings challenge us to preempt competitors.

The group facilitates our value-chain without pre-empting or constraining future flexibility.
The key representatives improve top-line talents without pre-empting or constraining future flexibility.

The challengers co-specify cross-platform, bifocal, evolutions.
The resources formulate a non-linear, bifocal and hyper-hybrid business equation.
Fully networked, company-first, industry market shifts challenge us to front-face bifocal value propositions.

Cross-pollinations deepen a manageable brand value.
The white-collar workforce potentiates manageable efficient frontiers.
Manageable portals motivate the market thinker.

The tolerably expensive, innovative, digital acceleration interacts with our distinctive workflows.
The decision makers strengthen distinctive swim lanes.
The enablers take control of structured, distinctive, organizational and high-level visibilities.
Probably, if we search for "wirecard double-digit growth" we'll find some fresh stuff for the CBSG...

Pasta! Statistics

4 August 2020 at 15:04
For your fun, here is in a chart the statistical distribution of the players of the Pasta! game, per level.

Click to enlarge

The yellow bars show the number of players who have completed level n (after the scoring system was implemented).
The bars in other colours show where the players are currently and the maximum level they are allowed to play (1, or the highest completed level + 1).

Together forever...

26 August 2020 at 08:51

Latest commit to the Corporate Bullshit Generator (live web app - source site 1 - source site 2): only one addition, but which one!

[prompt] produce_corporate_bullshit -h

-1, --one, --sig single sentence
-b, --bulk EXPR infinite loop; shows only sentences with EXPR
-h, --help this help
-w, --workshop workshop format

[prompt] produce_corporate_bullshit -b "together, we"

Together, we synergize a workforce-focused, deterministic, global touch-base.
Together, we prioritize well-implemented accelerators.
Together, we solutionize profiles.
Together, we execute on priorities.
Together, we enhance game-changing strategic staircases.
Together, we identify known unknowns.
Together, we facilitate our competitive success.
Together, we whiteboard outward-looking challenges.
Together, we create momentum.

Zip-Ada: the new Zip_Entry_Stream output stream

2 September 2020 at 13:05

The latest addition to Zip-Ada (commits #792 to 794) is the possibility of writing contents to a Zip file (or more generally, a Zip stream) as an output stream. You (the programmer) don't need to store contents into some buffer and design an input stream in the Zip_Streams.Root_Zipstream_Type'Class type class to read that buffer, as it is the case for Add_Stream in the Zip_Create package.

How does new output stream work in practice? The best way is to show an example. Here is a reduced version of Test_Zip_Entry_Stream (you can find the full version in the test directory of the Zip-Ada project's sources):

      with Zip.Create;
with Ada.Command_Line, Ada.Text_IO;

procedure Test_Zip_Entry_Stream is
use Zip.Create;
use Ada.Command_Line, Ada.Text_IO;

Archive_Info : Zip_Create_Info;
Archive_File : aliased Zip_File_Stream;
Archive_Entry : aliased Zip_Entry_Stream_Type;
Text : File_Type;
Create_Archive (Archive_Info, Archive_File'Unchecked_Access, "test_zes.zip");
for I in 1 .. Argument_Count loop
Open (Archive_Entry);
Open (Text, In_File, Argument (I));
while not End_Of_File (Text) loop
String'Write (Archive_Entry'Access, Get_Line (Text));
Character'Write (Archive_Entry'Access, ASCII.LF); -- UNIX end-of-line
end loop;
Close (Text);
Close (Archive_Entry, "zes_" & Argument (I), use_clock, Archive_Info);
end loop;
Finish (Archive_Info);
end Test_Zip_Entry_Stream;


NB: this addition has been sponsored. It is used in an industrial software (robotics).

The open-source Zip-Ada project can be found at the following places:

AZip in action for duplicating a Thunderbird profile

18 September 2020 at 07:16

You want to copy your Thunderbird profile from machine A to machine B (with all mail accounts, passwords, settings, feeds, newgroups, ...) ? Actually it is very easy. From the user storage (on Windows, %appdata% (you get there with Windows key+R and typing %appdata%)), you copy the entire Thunderbird folder of machine A to the equivalent location on machine B, and that's it. The new active profile will be automatically selected since the file profiles.ini will be overwritten on the way.

Now, if you want or need to use a cloud drive or a USB stick for the operation, it's better to wrap everything in a Zip file (a single file instead of hundreds) to save time. Plus, you can store the Zip file in case of an emergency (losing data on both A and B machines).

With AZip, it's pretty easy: 

  • Shut down Thunderbird on both machines.
  • On machine A: drag & drop the Thunderbird folder on an empty AZip window.
  • Copy or move the Zip file.
  • On machine B: extract everything with another drag & drop, from AZip to the Explorer window with the %appdata% path. When asked "Use archive's folder names for output", say "Yes". When asked "Do you want to replace this file ?", say "All".

That's it!

Here a few screenshots:

Folder tree view - click to enlarge

You can squeeze the data to a smaller size (the LZMA format will be most of the time chosen over Deflate) with the "Recompress" button (third from the right).

After recompression - click to enlarge

Zip-Ada for Audacity backups

22 September 2020 at 18:21

Audacity is a free, open source, audio editor, available here.

If you want to backup you Audacity project, you can manually do it with "Save Lossless Copy of Project..." with the name, say, X, which will create X.aup (project file), a folder X_data, and, in there, a file called "Audio Track.wav".

Some drawbacks:

  • It is a manual operation.
  • It is blocked during playback.
  • Envelopes are applied to the "Audio Track.wav" data. So data is altered and no more a real lossless copy of the project. Actually this operation is something between a backup and an export of the project to a foreign format.

A solution: Zip-Ada.

The latest commit (rev. 796) adds to the Preselection method a specific configuration for detecting Audacity files, so they are compressed better than with default settings.

Funny detail: that configuration makes, in most cases, the compression better than the best available compression with 7-Zip (v.19.00, "ultra" mode, .7z archive).

The compressing process is also around twice as fast as 7-Zip in "ultra" mode. This is no magic, since the "LZ" part of the LZMA compression scheme spends less time finding matches, in the chosen configuration for Zip-Ada.

A backup script could look like this (here for Windows' cmd):

rem --------------------------
rem Nice date YYYY-MM-DD_HH.MM
rem --------------------------

set year=%date:~-4,4%

set month=%date:~-7,2%
if "%month:~0,1%" equ " " set month=0%month:~1,1%

set day=%date:~-10,2%
if "%day:~0,1%" equ " " set day=0%day:~1,1%

set hour=%time:~0,2%
if "%hour:~0,1%" equ " " set hour=0%hour:~1,1%

set min=%time:~3,2%

set nice_date=%year%-%month%-%day%_%hour%.%min%

rem --------------------------

set audacity_project=The Cure - A Forest

zipada -ep2 "%audacity_project%_%nice_date%" "%audacity_project%.aup" "%audacity_project%_data\e08\d08\*.au"

GWindows: Desktop shortcuts and Explorer context menu

29 September 2020 at 10:13

Just in time to celebrate the 25th anniversary of Windows as we know it (ouch!), here is a gadget-ish contribution to the GWindows library, the open-source Ada library for MS Windows, available here and here.

In there gwindows/contrib directory, there is gwin_util.ads (spec.) and gwin_util.adb (body), and in gwindows/contrib/test, there are demos. All that is available comfortably through the gwindows_contrib.gpr project file in the gwindows directory.

  1. test_shortcut.adb:

  2. test_explorer_context_menu.adb:

AZip 2.40 - Windows Explorer context menus

3 October 2020 at 18:00

New release (2.40) of AZip.

The long-awaited Windows Explorer integration is there:

Context menu for a file

Context menu for a folder

This integration is activated upon installation or on demand via the Manage button:



This new version is based on the Zip-Ada library v.57 and includes its recent developments.


Zip-Ada v.57

3 October 2020 at 20:55
 New in v.57 [rev. 799]:

  - UnZip: fixed bad decoding case for the Shrink (LZW) format,
        on some data compressed only by PKZIP up to v.1.10,
        release date 1990-03-15.
  - Zip.Create: added Zip_Entry_Stream_Type for doing output
        streaming into Zip archives
  - Zip.Compress: Preselection method detects Audacity files (.aup, .au)
        and compresses them better


Zip-Ada is a pure Ada library for dealing with the Zip compressed
archive file format. It supplies:
 - compression with the following sub-formats ("methods"):
     Store, Reduce, Shrink (LZW), Deflate and LZMA
 - decompression for the following sub-formats ("methods"):
     Store, Reduce, Shrink (LZW), Implode, Deflate, Deflate64,
     BZip2 and LZMA
 - encryption and decryption (portable Zip 2.0 encryption scheme)
 - unconditional portability - within limits of compiler's provided
     integer types and target architecture capacity
 - input archive to decompress can be any kind of indexed data stream
 - output archive to build can be any kind of indexed data stream
 - input data to compress can be any kind of data stream
 - output data to extract can be any kind of data stream
 - cross format compatibility with the most various tools and file formats
     based on the Zip format: 7-zip, Info-Zip's Zip, WinZip, PKZip,
     Java's JARs, OpenDocument files, MS Office 2007+,
     Google Chrome extensions, Mozilla extensions, E-Pub documents
     and many others
 - task safety: this library can be used ad libitum in parallel processing
 - endian-neutral I/O


Main site & contact info:
Project site & subversion repository:
GitHub clone with git repository:


HAC v.0.075: time functions: goodies for scripting tasks

20 October 2020 at 19:44
Today, HAC has a few more functions, from Ada.Calendar. I have added them in order to translate a Windows cmd script to Ada (with HAC_Pack). More precisely, it's "save.cmd", which takes a snapshot of the sources of the HAC system and other key files. This snapshot is a Zip archive and has a time stamp in its name, like "hac-2020-10-20-20-27-36-.zip". Hence the addition of standard functions like Year, Month, etc. The script is very practical for making backups between commits via subversion or git, and for other purposes. Now the script is called "save.adb" and does the same job, but not only on Windows, but also on Linux or other Operating Systems. Since the Zip compression is also programmed in Ada (Zip-Ada), you have in that script example a cool situation of Ada invading your computer 😊.

Here, a screenshot of the added functions running from the LEA editor (hum, also a full Ada software, by the way!):

HAC 0.075 running from LEA. Click to enlarge.

More to come soon with some subprograms stemming from Ada.Directories.

HAC is free and open-source, you can find it here and here.

HAC v.0.076: Ada.Directories-like subprograms

24 October 2020 at 07:12

After Ada.Calendar-like subprograms, here are now Ada.Directories-like subprograms which facilitate shell scripting with HAC in a portable way.

As usual, the easiest way to see the full set of additions is to look into HAC_Pack's specification, hac_pack.ads:

      function Current_Directory return VString;

procedure Set_Directory (Directory : String) renames Ada.Directories.Set_Directory;
procedure Set_Directory (Directory : VString);

procedure Copy_File (Source_Name : String; Target_Name : String);
procedure Copy_File (Source_Name : VString; Target_Name : String);
procedure Copy_File (Source_Name : String; Target_Name : VString);
procedure Copy_File (Source_Name : VString; Target_Name : VString);

procedure Delete_File (Name : String) renames Ada.Directories.Delete_File;
procedure Delete_File (Name : VString);

function Exists (Name : String) return Boolean renames Ada.Directories.Exists;
function Exists (Name : VString) return Boolean;

procedure Rename (Old_Name : String; New_Name : String) renames Ada.Directories.Rename;
procedure Rename (Old_Name : VString; New_Name : String);
procedure Rename (Old_Name : String; New_Name : VString);
procedure Rename (Old_Name : VString; New_Name : VString);
HAC is free and open-source, you can find it here and here.