Earlier quoted context omitted.
Shouldn't your body be after the condition check? Otherwise you get one iteration even if your condition was false to begin with?
I specifically asked for a do while loop.
Writing a C compiler in 500 lines of Python (2023)
91–100 of 114 posts
Re: Writing a C compiler in 500 lines of Python (2023)
#92After many years of programming in other languages, I finally learned C, and came to realize that there aren't actually any compilers that implement all of the C spec. Even GCC and Clang have their grey areas and their bugs. Before this, I had thought that C was a simple language. An idea propped up by articles likes this, as well as the oft touted fact that nearly every embedded system has a C compiler; no matter wh…
"Before this, I had thought that C was a simple language." It was a simple language. It can still be used that way As hobbyist I write simple programs that can be compiled with -std=c89 I use these programs every day. They are faster than their equivalents in python, smaller than their equivalents in go, and require less resources or dependencies to compile than their equivalents in rust It is easy to take something…
Re: Writing a C compiler in 500 lines of Python (2023)
#93After many years of programming in other languages, I finally learned C, and came to realize that there aren't actually any compilers that implement all of the C spec. Even GCC and Clang have their grey areas and their bugs. Before this, I had thought that C was a simple language. An idea propped up by articles likes this, as well as the oft touted fact that nearly every embedded system has a C compiler; no matter wh…
"Before this, I had thought that C was a simple language." It was a simple language. It can still be used that way As hobbyist I write simple programs that can be compiled with -std=c89 I use these programs every day. They are faster than their equivalents in python, smaller than their equivalents in go, and require less resources or dependencies to compile than their equivalents in rust It is easy to take something…
Generally, I do not use any third party libraries besides the "standard" ones that come with UNIX-llike OS
I do not _have_ to use other third party libraries, it's a choice; I choose not to use them for personal reasons that may or may not apply to anyone else
Re: Writing a C compiler in 500 lines of Python (2023)
#94Earlier quoted context omitted.
Yes, function prototypes were introduced in the first ANSI version of C, IIRC, which came some years after the original C. The prototype feature was described in the second version of the classic K&R C book, The C Programming Language.
Function prototypes came to ANSI/ISO C via the ongoing work on ISO C++.
I was talking w.r.t. the earlier version of C, and not in connection with C++.
Re: Writing a C compiler in 500 lines of Python (2023)
#95Earlier quoted context omitted.
I used to write software on my HP calculator, when I was bored in classes, before smartphones existed. It used a tokenized language called RPL, and the editor would read and parse just enough tokens to fill up the screen. I miss how fast it was, compared to modern computers. VS Code is much laggier in comparison.
Which model of HP calculator? And what kinds of programs could you write with it?
HP's calculators are pretty capable, with built-in commands for image processing, so RPL programs could rival the capabilities of assembly language programs on TI-8x calculators.
Re: Writing a C compiler in 500 lines of Python (2023)
#96Earlier quoted context omitted.
I used to write software on my HP calculator, when I was bored in classes, before smartphones existed. It used a tokenized language called RPL, and the editor would read and parse just enough tokens to fill up the screen. I miss how fast it was, compared to modern computers. VS Code is much laggier in comparison.
I used to dream about owning a programmable calculator in the late 70s/early 80s, but by 1980 we had Apple ][s in my high school and in 1982, I was able to use the PCs in college, first programming in BASIC and later Turbo Pascal, which was the best PC development tool in the 1980s. Most of my classes were in Pascal. My first job was in C++ and I was doing C++ by 1993 and still am. Now I write Python for fun.
Re: Writing a C compiler in 500 lines of Python (2023)
#97Earlier quoted context omitted.
Function prototypes came to ANSI/ISO C via the ongoing work on ISO C++.
Doesn't matter where it came from - in the context of my previous comment. I was talking w.r.t. the earlier version of C, and not in connection with C++.
Re: Writing a C compiler in 500 lines of Python (2023)
#98Earlier quoted context omitted.
Which model of HP calculator? And what kinds of programs could you write with it?
I had a 48S then a 49g+. I played around with a few games and a Magic Eye style ( https://en.wikipedia.org/wiki/Random_dot_stereogram ) 3D image generator, as well as programs to do actual math in my math classes. The math teachers teachers at my high school had a policy that, on exams, students could run any program they wrote, so I wrote programs to do the math and "show my work". Solving equations on paper was hal…
I had asked because I was thinking of getting some small device like a PDA or programmable calculator, to use to write small programs for fun and possibly actual use, when I'm not with my laptop.
I am not sure if any PDAs or such calculators are still made these days. I have googled some, but so far did not find any, IIRC. So I may have to buy a used calculator or PDA, if I can find a model I like.
I used to have 2 different Palm PDA models earlier, first a V and then a Zire, but I never did any programming with them, although I do remember trying to use Pippy, a Python 2.x version ported to the Palm. But it used to crash all the time, so I could not really do any programming on it, unfortunately.
Re: Writing a C compiler in 500 lines of Python (2023)
#99Earlier quoted context omitted.
I had a 48S then a 49g+. I played around with a few games and a Magic Eye style ( https://en.wikipedia.org/wiki/Random_dot_stereogram ) 3D image generator, as well as programs to do actual math in my math classes. The math teachers teachers at my high school had a policy that, on exams, students could run any program they wrote, so I wrote programs to do the math and "show my work". Solving equations on paper was hal…
Thanks for the reply. I had asked because I was thinking of getting some small device like a PDA or programmable calculator, to use to write small programs for fun and possibly actual use, when I'm not with my laptop. I am not sure if any PDAs or such calculators are still made these days. I have googled some, but so far did not find any, IIRC. So I may have to buy a used calculator or PDA, if I can find a model I li…
Every major calculator manufacturer makes modern back-lit full-color graphing calculators, like HP's Prime, TI's Nspire, and Casio's ClassWiz, but they don't have the charm of reflective LCDs.
The best bang for your buck is probably a Casio FX 7400, 9750 or 9860 GIII series, which have Python interpreters. If you want something more fun, albeit only programmable in BASIC, Casio's CFX have an oddball color display that doesn't use subpixels. (See this video: https://www.youtube.com/watch?v=jLew3Dd3IBA)
Re: Writing a C compiler in 500 lines of Python (2023)
#100Earlier quoted context omitted.
Thanks for the reply. I had asked because I was thinking of getting some small device like a PDA or programmable calculator, to use to write small programs for fun and possibly actual use, when I'm not with my laptop. I am not sure if any PDAs or such calculators are still made these days. I have googled some, but so far did not find any, IIRC. So I may have to buy a used calculator or PDA, if I can find a model I li…
HP 's graphing calculators are the best, but they can be very expensive. Every major calculator manufacturer makes modern back-lit full-color graphing calculators, like HP's Prime, TI's Nspire, and Casio's ClassWiz, but they don't have the charm of reflective LCDs. The best bang for your buck is probably a Casio FX 7400, 9750 or 9860 GIII series, which have Python interpreters. If you want something more fun, albeit…