Open in app

Sign In

Write

Sign In

Paul J. Lucas
Paul J. Lucas

16 Followers

Home

About

Jun 26, 2022

Go-tcha: Shallow Polymorphism

Introduction Polymorphism (or, more specifically, subtype polymorphism) is one of the characteristics of an object-orient programming language (OOP) and is the ability of functions written to operate on objects of a particular type to operate on objects of subtypes also, sometimes doing different things. Conventional Inheritance & Polymorphism Consider the following example in C++: struct…

Go

5 min read

Go

5 min read


Jun 21, 2022

The Curious Case of the Disappearing “if”

Introduction I recently discovered a test-case that crashed cdecl: c++decl> explain int operator new(size_t) Assertion failed: (ast != NULL), function c_ast_unpointer_qual, file c_ast_util.c, line 404. zsh: abort (core dumped) c++decl FYI, it’s a negative test: operator new must return void*, not int. Briefly, cdecl is a program that helps you compose…

C

5 min read

C

5 min read


May 5, 2022

Obscure C99 Array Features

Introduction C99 introduced a number of new features for arrays. Even though C99 is over 20 years old, you seldom see these new features used in the wild. Because of that, you’re less likely to be familiar with them and so less likely to use them in your own code (but…

C

8 min read

C

8 min read


Apr 26, 2022

Why many Unix structs have prefixes

One thing I’ve long been curious about is why some Unix C struct fields are named such that they are prefixed by a common abbreviation. For example, for the sockaddr_in struct: struct sockaddr_in { short sin_family; unsigned short sin_port; struct in_addr sin_addr; }; all fields are prefixed by sin, an…

C

2 min read

C

2 min read


Apr 14, 2022

Function types in C (and C++)

Even after programming in C for decades, I occasionally still discover things about it. While typedefs of pointer to function are common, I just discovered that you can have typedefs of function by stumbling across their use in some open-source project (though I don't recall which one). …

C

1 min read

C

1 min read


Apr 7, 2022

What “volatile” does in C (and C++)

Introduction Occasionally, I come across either a use or explanation of the volatile keyword in C (or C++). Most often, that use or explanation is simply wrong. So here, hopefully once and for all, is what volatile in C (and C++) actually (and only) does. Legitimate Uses of volatile There are only three legitimate uses…

C

4 min read

C

4 min read


Mar 31, 2022

LLDB Custom Data Formatters for C in Python

Introduction If you use LLDB to debug C or C++ programs, you can customize the output of LLDB’s print (p) command to print the contents of variables in a more enlightening way than the default. You can even use Python to do it. However, pretty much all the examples I could…

Lldb

4 min read

Lldb

4 min read


Mar 19, 2022

Detecting Deletion

Suppose you’re implementing a class that uses a callback: class operation { public: struct done_callback { virtual ~done_callback(); virtual void operation_done( operation *op ) = 0; }; operation() { } bool perform( done_callback *cb ); private: bool success_ = false; }; bool operation::perform( done_callback *cb ) {…

Cplusplus

4 min read

Cplusplus

4 min read


Mar 11, 2022

Go-tcha: When assigning via pointer changes your type

I’m currently in the process of porting my CHSM (Concurrent Hierarchical Finite State Machine) project that has C++ and Java implementations to Go. Porting involves both rewriting the run-time library in Go as well as augmenting the CHSM compiler to emit Go code. Briefly, a CHSM is like an ordinary…

Go

5 min read

Go

5 min read


Mar 7, 2022

Medium Annoyances

Way back when Medium became the the new hotness, I created an account and gave it a try. I never published anything on the platform and abandoned it. Fast-forward several years to now when I recently gave it another try. I now recall why I abandoned it: Its editor is…

Medium

1 min read

Medium

1 min read

Paul J. Lucas

Paul J. Lucas

16 Followers

C++ Jedi Master

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech