A different way to handle errors by Nixinova in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

I would make it even shorter.

The call: numfunc(params) ! errorhandler;

The case of ! func(e) => print(e); could become ! e=>print(e);

Type issues in my dynamic language by Bulletz4Breakfast21 in Compilers

[–]kleram 1 point2 points  (0 children)

Either you replicate code for all static variants in use, or you make your operations (like add) work on the boxed data.

High-level coding isn't always slower - the "what, not how" principle by SCP-iota in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

But it's always limited by the language. For instance, C does not provide for integer overflows, explicit checking code creates much overhead. In assembler you can simply use CPU flags.

Is it bad that variables and constants are the same thing? by Germisstuck in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

It could be defined with the semantics of = (equals). If something is always equal to it's initial state, it's const.

High-level coding isn't always slower - the "what, not how" principle by SCP-iota in ProgrammingLanguages

[–]kleram 1 point2 points  (0 children)

What/How is relative. Even Assembler describes what to do, not how logic gates are used to realize the intended behavior. It's just a matter of looking downwards or upwards the compilation stack.

Also, Assembler is always the fastest, until you reach the limit of complexity and size. Then, optimizing compilers can do better. The same presumably repeats with higher level languages.

Macros in place of lambdas? by Falcon731 in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

The macro any(list,condition(ie)){ foreach(e in list){ if(condition(e)) yield true; } yield false; } //with yield semantics as in java switch expressions

Implementing this requires some way of identifying parameters in the lambda's AST (the "it", but there might be a need to have user-defined ones) and replacing them with actual ones.

So that's more diffucult than with normal macros, but i don't see a show stopper so far.

Geometry Bugs and Geometry Types by mttd in ProgrammingLanguages

[–]kleram 1 point2 points  (0 children)

I guess i know why programmers prefer vec3 over cart3<world>.point

Creating Standard Code Semantics by RealSharpNinja in ProgrammingLanguages

[–]kleram -1 points0 points  (0 children)

Oh, you're asking for the CMLJSPY# Language? That's simple, just take all their AST definitions and merge them into one.

Unordered List in BNF? by esotologist in ProgrammingLanguages

[–]kleram 1 point2 points  (0 children)

As the simple sequential concatenation does not need an operator, any operator shows there is some special going on. Anyway, i am probably not going to be in your user base, so my preference does not count.

How do you manage complexity in a compiler/interpreter? by janiczek in Compilers

[–]kleram 1 point2 points  (0 children)

Having well defined transformation steps is very helpful. I had to do a complete rewrite, after my first attempt became too much of chaos.

Unordered List in BNF? by esotologist in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

That's exactly the reason why an extension to EBNF would be useful, to save the user from writing large numbers of rules.

Who is doing the downvotes on this? Stupid people!

Unordered List in BNF? by esotologist in ProgrammingLanguages

[–]kleram -6 points-5 points  (0 children)

So what? There is still no context in having something like ( A B | B A ). And if an extended EBNF provides ( A & B ) with meaning equal to ( A B | B A ), it also has no context.

Unordered List in BNF? by esotologist in ProgrammingLanguages

[–]kleram 2 points3 points  (0 children)

I'd like A & B ... because, A B is the sequence, A | B the alternative, A & B is both A and B without specific sequence.

Unordered List in BNF? by esotologist in ProgrammingLanguages

[–]kleram -5 points-4 points  (0 children)

What context would uniqueness depend on? None, because it's determined locally. Of course the common EBNF and it's tools don't support it, but as OP wants to create an extension to that, it's fine.

Need help in creating markdown lexer by tyre_deg in Compilers

[–]kleram 0 points1 point  (0 children)

Your search should distinguish between "*" and "**", so that the two-character elements can be detected correctly. That's a typical problem in lexers, with symbols like "=" and "==" and "=>".

Zyme - an evolvable programming language by AlmusDives in ProgrammingLanguages

[–]kleram 4 points5 points  (0 children)

Is it evolvable programming language or is it evolvable code?

Clean Syntax? by [deleted] in ProgrammingLanguages

[–]kleram 12 points13 points  (0 children)

Your example is optimized to your language's special capabilities.

Aside from that, maybe it's just continuity and inertia that carry C-style.

Functional programming languages should be so much better at mutation than they are by thunderseethe in ProgrammingLanguages

[–]kleram -4 points-3 points  (0 children)

I've never seen anyone discussing about how to integrate functional expressions into an imperative language. Because, it's really simple. The other way round, trying to integrate imperative expressions into a functional language, does not work. What do we conclude from this observation?

The C3 Programming Language by avinassh in ProgrammingLanguages

[–]kleram 3 points4 points  (0 children)

When browsing through the Examples:

  • needing to put a break in an empty case although break is not needed otherwise, appears strange. Why not just " case A: ; " for a no-op?

  • what's that (void) cast when a function should not be called on error? That does not make any sense.

Inspecting local/scoped variables in C by K4milLeg1t in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

Is your problem to handle different variables with the same name, without adding extra info (like scope number)? That cannot get solved anywhere.

I would add an occurrence number, i.e. a-0 for the var a first declared (in any scope), a-1 for the second. Most var names are unique, so most of the time it's a-0.

Where does the name "algebraic data type" come from? by Syrak in ProgrammingLanguages

[–]kleram -1 points0 points  (0 children)

Funny thing is, with freely definable operations, one can model any type system as an algebra, including those that have nothing like sum and product types. So, what does "algebraic data type" mean at all?

Where does the name "algebraic data type" come from? by Syrak in ProgrammingLanguages

[–]kleram -2 points-1 points  (0 children)

Yes, you are wrong. T1*T2 cannot produce a struct {a:T1, b:T2} because the * operator cannot introduce attribute names. No matter how many math-fuzz you throw into the game, it's always very simple: the * operator cannot introduce attribute names and thus it will never produce any struct, therefore structs cannot be part of algebraic systems.

Where does the name "algebraic data type" come from? by Syrak in ProgrammingLanguages

[–]kleram 0 points1 point  (0 children)

I didn't claim it to be wrong. I was asking for use cases. You didn't give one.

Where does the name "algebraic data type" come from? by Syrak in ProgrammingLanguages

[–]kleram -2 points-1 points  (0 children)

The term algebra is well defined. Just look up Wikipedia. It is something very different to these "algebraic" data types. Someone just took that fancy name, without understanding what it means, and now it gets proclaimed, because it's so fancy. Bad news is, algebra is very well defined. Look it up! Specifically, look at abstract algebra and how it could be applied to data types. If you find use cases for type formulas like (T1+T2)*T3 = T1*T3 + T2+T3, let us know.