A couple of questions about arrays and slices

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jun 24 15:12:14 UTC 2023


On Saturday, June 24, 2023 8:43:00 AM MDT Cecil Ward via Digitalmars-d-learn 
wrote:
> I started out looking into a number of runtime library routines,
> but in the end it seemed quicker to roll my own code for a crude
> recursive descent parser/lexer that parses part of D’s grammar
> for expressions, and (again partial grammar) parser for string
> literal expressions and so on. I find certain special elements
> and execute actions which involve doing the AA lookup and
> replacing variable names with ordinal numbers in decimal in the
> output stream. Admission: The parsing is the thing that has to be
> fast, even though again the size of the D language text is not
> likely to be huge at all. But 40 years ago, I came from a world
> with 2k RAM and 0.9 MHz clock rates so I have developed a habit
> of always thinking about speed before I do anything, needful or
> not, to be honest. I once wrote a program that took 35 mins to
> evaluate 2+2 and print out the answer, so I’m now ashamed of
> writing slow code. Those were bad days, to be honest. 4 GHz+ and
> ILP is nicer.

Well, dmd is open source (and Boost-licensed, so it doesn't really have any
restrictions), so depending on what you're doing, it might make sense to
just take code from that (and it's very fast). IIRC, it pulls some fun
tricks like replacing identical strings with pointers to the same string so
that it can just compare pointers.

- Jonathan M Davis






More information about the Digitalmars-d-learn mailing list