Newbies thoughts on #drracket and #scheme in general

I have toyed with scheme/lisp in the past. Like most people, I have thought “that’s really cool,” and then gone back to programming in whatever language I was using before.

Lisp, I found, has a high barrier to entry, and requires a lot of infrastructure to get it to do something useful. Yes, of course, you could just type everything at the REPL, but you’re probably going to want to integrate it with emacs and quicklisp. It’s a little unfriendly out of the box.

DrRacket is a nice implementation, with a nice out-of-the-box experience. It’s IDE is a little clunky and a little slow, but it comes with all sorts of goodies. I was interested in fooling around with language design, which is a key feature of DrRacket.

The problem with DrRacket is that although it’s a little sluggish on my trusty old desktop, it is dead slow on my Raspberry Pi 2, even without the GUI. So I decided to do a little experimentation with Chicken Scheme.

Chicken proved to be much more to my liking speed-wise. Its libraries are nowhere near those available out of the box as with DrRacket, which of course is to be expected. What I thought to be a big flaw with Chicken was its impenetrable error messages. I had to send my definitions to the REPL function-by-function in order to find out whereabouts its was complaining.

Then we come to this little “gem”:

open-output-file: … If a file with the given name already exists, the effect is unspecified.

Really? Each Scheme implementation is allowed to just make up its mind as to what it wants to do? And the library user has to check the behaviour against each implementation?

DrRacket has the most sensible way of implementing it. The default behaviour is to raise an error, but there are optional keys for alternative behaviour, like ‘replace.

That’s good, but DrRacket’s keyword syntax is not standard Scheme. It doesn’t look like it’s in the up-and-coming R7RS, either. This means that for library writers, there’s a good chance that the code won’t be cross-implementation compatible. Considering how long R7RS seems to have been brewing, it seems to be lacking some pretty fundamental design choices.

BWTFDIK. Those guys are smarter than me. I’m just wondering if the design committee has some kind of cohesive goal for Scheme. C++ seems much more coherent in their vision.

Just my uneducated 2c.

Advertisements
Posted in Uncategorized | Leave a comment

Magic Hat Portfolio: FXPO stays in

Metals & Mining company FXPO (Ferrexpo) is due to be kicked out of the portfolio by rotation. The market reacted badly to its recent trading statement, and it has a Stockopedia StockRank of 68. It is down 36.4% since purchase.

I would be happy enough to kick it out of the portfolio and swap it in for something else. FXPO still qualifies for the Greenblatt screen, though. It has a low PE and high yield. Its debt levels are reasonable. It seems like the kind of stock that would qualify for a “Dorfman Robot” portfolio.

Value shares could well be due for a comeback (Any Day Now TM), so despite my displeasure, I’m going to keep it in. We shall see.

165p

Posted in Uncategorized | Leave a comment

#JPR: Johnston Press – in the news

JPR (Johnston Press) is trending on Twitter. It owns the Scotsman and Yorkshire Post, and it is looking to restructure or refinance its debt. Its share price is highly volatile, and claims that it “knows of no operational or corporate or other reason for the price movement.”

It share price is at 5.64p, giving it a market cap of £3.75m. Its revenue is around £200m, and Stockopedia gives it a momentum score of 3. Worrying!

Net debt seems to be £142m, and its only PBT since 2011 is £2.9m.

I would have thought that the situation was unsalvageable. If I held shares, I would sell out at any price.

5.64p

Posted in Uncategorized | Leave a comment

RPC followup

A year ago I wrote about RPC (https://mcturra2000.wordpress.com/2017/07/12/rpc-my-own-thoughts/), presenting a negative view. Since then, the shares have fallen 3.6% from 773p to 745p, whilst the ASX has risen 4.0% from c. 4025 to 4187.

What worried me was:

  • a chart that seemed to be reversing
  • debt that was too high for my liking
  • mediocre ROCE
  • acquisition-hungry

I guess I get to claim “victory” in my prediction, although it could easily have been wrong. I am just doing this write-up for completeness.

Reading the BBs (Bulletin Boards), the subject of acquisitions is mentioned quite a lot. analysts at Northern Trust thought that acquisitions were disguising structural problems. At the time, it said that it had completed 10 deals in 12 months. They said that the management had been encouraged to pursue value-destructive acquisitions, and had some of the most aggressive accounting they had seen.

Stockopedia gives it a quality score of 84, which is quire respectable. The StockRank is 81, also quite respectable. So perhaps I had been too negative in my original assessment. For my money, I am happy enough to be out of the share.

745p

I’m not a footy fan, but good luck to England in the semis tonight. Is football coming home? We shall see. Stay safe out there.

Posted in Uncategorized | Leave a comment

Magic Hat: MGNS in, LSL out

The MHP (Magic Hat Portfolio) on Stockopedia (http://www.stockopedia.com/fantasy-funds/magic-hat-463/) is an experiment by me to see if a human can improve on a mechanical Greeblatt Magic Formula screen. I am trying to weed out “mistakes” that I feel the screening commits: unseasoned companies, scams, foreign companies (particularly Chinese), fishy accounting, and statistical quirks. Apart from that, I am agnostic as to the sector the company operates in, although I will try to avoid heavy concentration in any one sector. I will mostly apply “Strategic Ignorance”, by which I mean that I wont try to be clever in my stockpicking. My picking will be mostly mechanical. A summary of most of my Magic Hat articles can be found on the web page http://www.markcarter.me.uk/money/greenblatt.htm This will allow you to see, at a glance, what shares have been bought and sold in the past, as well as what shares have been rejected from consideration and why.

LSL leaves the portfolio by rotation, having gained 10% over one year. Not fantastic, but it beat the ASX (FTSE All Share Index), which was only up 0.4%.

Construction & Engineering company MGNS enters the portfolio on account of qualifying for the Greenblatt Screen and having a Stockopedia StockRank in the 90’s.

That’s enough talk about money. It’s time to go outside and enjoy some sunshine. Stay safe.

Posted in Uncategorized | Leave a comment

Magic Hat: CTO in, EPWN out

The MHP (Magic Hat Portfolio) on Stockopedia (http://www.stockopedia.com/fantasy-funds/magic-hat-463/) is an experiment by me to see if a human can improve on a mechanical Greeblatt Magic Formula screen. I am trying to weed out “mistakes” that I feel the screening commits: unseasoned companies, scams, foreign companies (particularly Chinese), fishy accounting, and statistical quirks. Apart from that, I am agnostic as to the sector the company operates in, although I will try to avoid heavy concentration in any one sector. I will mostly apply “Strategic Ignorance”, by which I mean that I wont try to be clever in my stockpicking. My picking will be mostly mechanical. A summary of most of my Magic Hat articles can be found on the web page http://www.markcarter.me.uk/money/greenblatt.htm This will allow you to see, at a glance, what shares have been bought and sold in the past, as well as what shares have been rejected from consideration and why.

EPWN (Epwin) leaves the portfolio by rotation, having lost 33% during its year in the portfolio. Its Stockopedia StockRank is 95, so for all I know, it’s still a good stock to hold. Its share price to free cashflow is approaching 10, and debt looks reasonable, so it may be in quite good value territory is the price goes down much more.

Construction and Engineering company CTO (T Clarke) enters the portfolio, having net cash, a P/FCF of 7.3, and a StockRank of 94. Looks good. It seems to have wafer-thin profit margins, which might put people off.

Well, that’s me for the month. The portfolio change is a little earlier than usual, because I’m taking a much-undeserved holiday to Majorca. Take care, and stay safe out there.

Posted in Uncategorized | Leave a comment

Using std::variant as YYSTYPE/yylval in gnu bison for C++17

My blang project, which is a BASIC interpreter, uses  top-down recursive-descent parsing. I have been wondering if I could obtain better mileage from using flex/bison.

Bison is quite old now, having last being updated in 2015 at version 3.0.5. So it is not up to speed with the latest C++ standards.

Although bison does support C++, and even it’s own spin on variant values for YYSTYPE/yylval, I found the documentation impenetrable. It almost seems to work, but I couldn’t get it to do quite what I wanted. You seem to be faced with the alternative with adding a whole mass of infrastructure to accommodate bison, or else do things the C way. The documentation on using C++ in bison is opaque.

My real problem stems from being able to express the type of the parse node. The C way is to use a union of pointers: not the sort of thing we want when programming in C++.

Now, it turns out that you can use a variant for YYSTYPE. I present below a simple skeleton file (variant.yy):

%{
#include <string>
#include <variant>
typedef std::variant<std::string, double> value_t;
#define YYSTYPE value_t
extern YYSTYPE yylval;
int yylex();
void yyerror(char const *s);
int main();
%}

%token FOO

%%

top:
 FOO { $$ = $1; }

%%

int yylex()
{
 yylval = std::string("hello");
 return FOO;
}

void yyerror(char const *s)
{
}

int main()
{
 return 0;
}

It is available as a gist .

There’s a lot wrong with this example, of course. yylex() doesn’t do very much, for example, and main() doesn’t even call yyparse(). But that’s not the point. The point is to show how you set up a parser to generate variants as heterogeneous intermediate branches of the parse tree.

I am only at the experimental stage of rewriting my blang parser, but I am hopeful that the code I write using bison will be shorter than my top-down implementation. I shall report back my findings when they are available.

Posted in Uncategorized | Leave a comment