@zwarich@hachyderm.io avatar

zwarich

@zwarich@hachyderm.io

Programming language & compiler enthusiast, computer architect, and creator of Rosetta 2.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

pervognsen, to random
@pervognsen@mastodon.social avatar

I think I've heard people use at least four significantly different pronunciations of "Dyck" when talking about "Dyck languages" which might be a new record.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen I have always been curious whether it's possible to make a practical grammar formalism or parsing methodology (inspired by the Chomsky-Schützenberger Theorem) decomposing languages into a Dyck language and a regular language.

zwarich, to random
@zwarich@hachyderm.io avatar

Does anyone have a good solution for writing a recursive descent parser in C/C++ with the following constraints?

  • produces an ordinary heterogeneous AST
  • handles multiple errors (while being able to produce a partial syntax tree for the rest)
  • doesn't use exception handling or setjmp/longjmp

Whenever I crank something like this out, I feel like I'm missing something and writing too much code. I guess I could just use a morass of macros?

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Interesting approach. it forces you to enumerate your errors explicitly, instead of just having generic syntax errors everywhere, and it provides a bit of back pressure to encourage you to share them between occurrences when appropriate.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen In languages with more common uses of exceptions, I’ve seen parsers that always throw exceptions on unexpected tokens and expect the first level that can actually handle it to catch those exceptions. It’s maybe a bit more annoying to make this lossless, though.

zwarich, to random
@zwarich@hachyderm.io avatar

My code after learning how unions interact with the C memory model: https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fdb5839d1409806633fdb/chibicc.h#L228-L291

zwarich,
@zwarich@hachyderm.io avatar

@foonathan There are minor issues, but the biggest one by far is the “visible union rule” from N685:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n685.htm
The related GCC issue is a perennial source of amusement:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892
While even the most charitable interpretations of the rule have the property that adding a type declaration with no uses affects codegen, the most conservative interpretations render TBAA useless.

pervognsen, to random
@pervognsen@mastodon.social avatar

Every time I have to install a new driver and run GeForce Experience, I'm reminded that the last thing I want with my GPU driver installer is an "experience".

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen ... upscaled using AI from a single off-black pixel.

pervognsen, to random
@pervognsen@mastodon.social avatar

I'm trying to find posts about this but my Google-Fu is letting me down: does anyone remember something about a microcode bug for one of the Zens where RDTSC had drastically reduced granularity?

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Do you actually see repeated RDTSC values on contemporary x86 CPUs, or am I misunderstanding the assertion? Rosetta will definitely give them frequently, due to a different underlying timebase.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Interesting that AMD might be non-strictly monotonic. We were only testing Intel hardware for the obvious reasons. Of course, from the perspective of someone writing software, I would never rely on this either way.

pervognsen, (edited ) to random
@pervognsen@mastodon.social avatar

My bed-time reading for the last week has been the old Randell and Russell book on ALGOL 60 implementation (with a foreword by Dijkstra). It's a very interesting (and influential) treatment. https://www.softwarepreservation.org/projects/ALGOL/book/Randell_ALGOL_60_Implementation_1964.pdf

ALGOL 60 included recursion at Dijkstra's last-minute insistence, which I believe at that time had only been supported in Lisp (which was still brand new and initially wasn't really an "implementation language" per se).

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen This paper is about a really good example of this phenomenon from mathematics:
https://www.jstor.org/stable/3109881

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Yeah, it's a good read. I am blessed to have done graduate school in functional analysis before I became a programmer. While I'm not sure it's the most happening area of math today, the history is fascinating.

This now-Dover book is another great history of the confusing development of now familiar concepts, with lots of side quests:
https://store.doverpublications.com/0486488411.html

pervognsen, to random
@pervognsen@mastodon.social avatar

Random folklore question: when did the phrase/idiom of "tying the knot" for fixed points enter the functional programming jargon? I first picked it up from Oleg's articles on his website in the early/mid 2000s but I don't know if he originated it.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Here it is from 1996 (on pg. 167):
https://apps.dtic.mil/sti/pdfs/ADA326493.pdf

zwarich, to random
@zwarich@hachyderm.io avatar

@graydon Do the results of the .NET green threads experiment make you feel somewhat vindicated?
https://github.com/dotnet/runtimelab/issues/2398
Unless I am mistaken, .NET (via F# and then C#) is the source of the contemporary async/await model.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen @graydon In the original .NET context, most of those problems have easier solutions due to the existence of a GC’d runtime, at least until you hit the FFI.

pervognsen, to random
@pervognsen@mastodon.social avatar

Started to sketch out the parsing example with the left-fold postorder consumer design. I haven't had the time to write tests yet, but hey it passes the type checker. Figured I'd post up the WIP and I'll finish it off tomorrow.

https://gist.github.com/pervognsen/cf7f77a66e614fc4b32858e78918fdf5

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen What motivated you to originally do this in C? Was it just wanting to have multiple consumers?

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen You mention streaming parsers, but did you ever attempt using streaming syntax tree representations? Carbon using a (mostly?) postorder streaming representation has brought it back into the public consciousness recently.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen Yeah that's what I ended up doing in a few places. It gets trickier if you're using a mixed bracketed/RPN representation, since you can't delete the placeholder with backpatching (unless you want later passes to be able to handle a meaningless entry, which is pretty annoying).

How did you end up handling lvalues in your most streaming one-pass compiler?

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen That's an impressive amount of ideological purity. Amusingly, despite being interested in one-pass compilers, from a language user perspective I find Haskell/Rust-style unordered top-level definitions to be more ergonomic.

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen I definitely miss explicit mutual recursion from ML-family languages for that same reason. Usually when functions are mutually recursive you have additional invariants, so marking them and requiring them to nearby helps with that.

zwarich,
@zwarich@hachyderm.io avatar

@foonathan @pervognsen What's the best talk you gave on lexy?

pervognsen, (edited ) to random
@pervognsen@mastodon.social avatar

For limited-field reference counting, is it standard to use an address-hashed overflow table with wider counts? I was thinking about a problem where this seems like an attractive option. And then I remembered that Sean used this idea (in a slightly different form involving terrain lighting but essentially still reference counting) as a worked example in his 1998 article on software patents: https://nothings.org/computer/patents.html

zwarich,
@zwarich@hachyderm.io avatar

@pervognsen I opened up the GC book (new edition) expecting to find an old reference for this, but the "reference count overflow" section doesn't even mention it as an option.

regehr, to random
@regehr@mastodon.social avatar

I found the guy! someone hire him quick!!!

zwarich,
@zwarich@hachyderm.io avatar

@regehr If I was interviewing someone who claimed this publicly, my interview slot would be all about 'restrict'.

zwarich, to random
@zwarich@hachyderm.io avatar

We need a systems language that just gives up on undefined padding, makes padding bytes zero, and opens the door to a future of bytewise equality/hashing.

zwarich,
@zwarich@hachyderm.io avatar

@foonathan I considered that. Are you happy with how it turned out in practice?

zwarich,
@zwarich@hachyderm.io avatar

@foonathan C++ has the wonderful property of allowing you to do anything you want, but with an exponential back-on of discomfort along the way.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • mdbf
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • JUstTest
  • GTA5RPClips
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • megavids
  • Leos
  • cisconetworking
  • lostlight
  • All magazines