Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment Re:Such potential (Score 1) 520

Parsing arbitrary user-written code is more involved than generating code. When you generate code, you deal only with a subset of the language that your generator emits. When you parse code, you have to deal with essentially the entire language.

Sure, but parsing only has to be implemented once, and then everyone can use it.

And, coincidentally, Python contains its own parser in the standard library.

Comment Re:Such potential (Score 1) 520

Ah, I see what you mean now.

Yes, in a case like that - for templating languages and such - you really do want the explicit block terminator. And that's what people do to Python in similar circumstances - just add it. Have a look at Bottle's SimpleTemplate engine - you might actually be able to reuse that directly as it's very lightweight, and it's generic and bare-bones enough to not really be tied to HTML in any way.

Comment Re:Such potential (Score 1) 520

It's actually trivial to generate Python code that way, if all you care about is syntactic correctness (rather than, say, preservation of whitespace) - you simply translate indentation into virtual "brackets" (which is pretty much implicit in AST form - and you do want to work with an AST for any kind of reliable codegen, anyway), splice your code in, then translate it back.

If you want to preserve the original indentation, it's just a little bit harder, but not much. Basically, you just need to remember the whitespace information on your AST nodes. Then, when you reconstitute the code from the AST, you can do so with character-for-character precision.

(Source: personal experience. I work on a Python IDE that has to deal with lots of that kind of stuff for e.g. implementation of refactoring. Once we had our whitespace-preserving AST, the rest was and remains easy.)

Comment Re:So? (Score 1) 520

So far as I can see (and also from your link below), there isn't anything there that's not in D, except possibly for slightly better syntax. But syntax is a small enough thing, and given that D is already fairly mature and has a large community with several prominent people spearheading its further development and popularization, the rational choice would seem to be D.

Comment Re:Ask the Linux distributors to change (Score 1) 755

The problem is that if developers will go ahead and write systemd-only software (like GNOME guys are keen on doing), then any distro that wants to include that software will also have to switch to systemd, and that becomes a very strong leverage on distro maintainers when we're talking about popular software.

Comment Re:A pretty pointless study I would say (Score 1) 677

It shouldn't really be surprising - Ada is clearly derived from Pascal, and Pascal is both a simplification and an extension of Algol-60 (with Algol-W as the intermediate step) - removing exotic stuff like label variables and call by name, but extending the type system significantly (with records and pointers, most importantly). Simula is also a direct derivative of Algol-60 - if I remember correctly, it's actually a strict superset, and retains the entire Algol-60 language as a core, but then adds OOP constructs on top. So large parts of the keyword vocabulary are the same, for example.

Algol-68 is another interesting one. Doesn't really have much with common with Algol-60, but you'll find a lot of precursors of C syntax and semantics in it. Pretty much all C built-in types come from it, including things like "short int" and "long long int", for example, as does the general "type name = initializer" syntax for variable declarations. I've already mentioned structs and unions. OTOH, it still uses keywords rather than curly braces to delimit blocks, so it looks like some strange cross between C and Pascal from a modern perspective.

Comment Re:A pretty pointless study I would say (Score 1) 677

Dijkstra wrote it in 1968. At that time, there was still an active debate over whether structured programming (i.e. loops and functions) was genuinely useful, or a fad that made compilers more complicated than they need to be, and generate suboptimal code. Dijkstra's letter was basically an argument in favor of the former camp, which has ultimately won by 1970s. So yes, it's not really a meaningless comparison given today's state of affairs.

Comment Re:A pretty pointless study I would say (Score 1) 677

When Djikstra wrote his article, languages like C and Pascal with while() and do {} while() loops did not exist.

If you think that while-loops were popularized by C or Pascal, I have a surprise for you. Note, this is from 1960, but the first version of the language already had in in 1958!

Heck, when Dijkstra wrote it, there was already Simula-67 out there, which had classes and objects, virtual functions with overriding, and access modifiers (on top of everything Algol had). If you ever wondered where "virtual" and "new" in C++ came from by the way, that's its origin.

And then there was Algol 68, with structs and unions (again, that's where C stole that stuff), function pointers, and a lot of other gimmicky stuff. Also, "void".

Most of the things in programming are much older than people assume these days.

Comment Re:Something python has taught me... (Score 1) 677

I don't think I've _ever_ used GOTO in several decades of programming C.

Have you ever done error handling when writing C? What do you normally do when you have, say, two socket descriptors opened, and then three function calls, each of which may fail with an error and require you to bail out, while closing both of those sockets?

Slashdot Top Deals

Remember to say hello to your bank teller.

Working...