Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 27 2020 12:56

    Clashsoft on cleanup-library

    fix: Use extensions for ArrayOp… fix: Use extensions for Primiti… fix: Update code style in Range… and 1 more (compare)

  • Oct 27 2020 11:32

    Clashsoft on develop

    docs: Remove isitmaintained bad… docs: Add GitHub Actions status… docs: Move tables below descrip… (compare)

  • Oct 27 2020 10:25

    Clashsoft on master

    (compare)

  • Oct 27 2020 10:22
    Clashsoft edited #519
  • Oct 27 2020 10:21
    Clashsoft labeled #519
  • Oct 27 2020 10:21
    Clashsoft labeled #519
  • Oct 27 2020 10:20

    Clashsoft on develop

    ci: Add Java CI workflow for Gi… (compare)

  • Oct 27 2020 10:20

    Clashsoft on ci

    (compare)

  • Oct 27 2020 10:17

    Clashsoft on develop

    fix(library): Normalize \r and … (compare)

  • Oct 27 2020 10:16

    Clashsoft on ci

    fix(library): Normalize \r and … Merge branch 'develop' into ci (compare)

  • Oct 27 2020 10:05

    Clashsoft on ci

    ci: Test logging (compare)

  • Oct 27 2020 09:57

    Clashsoft on ci

    test: Fix MarkerPrinterTest (compare)

  • Oct 27 2020 09:51

    Clashsoft on ci

    test: Fix MarkerPrinterTest (compare)

  • Oct 27 2020 09:44

    Clashsoft on ci

    fix(gensrc): Handle \r and \r\n… fix(library): Handle \r and \r\… fix(library): Handle \r and \r\… and 3 more (compare)

  • Oct 27 2020 09:44

    Clashsoft on develop

    build: Use v0.48.0-alpha.3 for … (compare)

  • Oct 27 2020 09:39

    Clashsoft on line-separators

    (compare)

  • Oct 27 2020 09:39

    Clashsoft on develop

    fix(gensrc): Handle \r and \r\n… fix(library): Handle \r and \r\… fix(library): Handle \r and \r\… and 1 more (compare)

  • Oct 27 2020 09:39
    Clashsoft closed #519
  • Oct 27 2020 09:39
    Clashsoft edited #519
  • Oct 27 2020 09:39
    Clashsoft edited #519
BourgondAries
@BourgondAries
I think that's confusing and makes the language feel like bash, unlike Java/C++/C#
Especially the postfix unary > operator. When does this rule not apply?
foo ()  // Call postfix () operator
foo()  // Call foo method
The main issue I have with this is that the programmer will constantly be scratching his head trying to figure out which method gets called, and which doesn't.
Clashsoft
@Clashsoft
For the postfix >, it would be the same with or without whitespace. That matters is bar<... vs bar < ...
Former is generic method call, latter is less than operator.
I think Swift has a similar problem because it doesn't have a new operator, so you get things like Foo(Dictionary<String, String>(), bar). I could never find a single resource about the parsing mechanics behind this, ever.
BourgondAries
@BourgondAries
My guess is that the lexer collects tokens as well as some symbols
So Generic< may be a token called template_start or something.
Clashsoft
@Clashsoft
Yeah, so Swift has significant whitespace. I will most likely do it the same way at least for generics, because I absolutely hate my current style. Previously, I had receiver.methodName#[Types...](arguments...), but I didn't like that either.
BourgondAries
@BourgondAries
Do generics need interfaces?
(in your lang)
Clashsoft
@Clashsoft
What do you mean? You can have both generic classes and generic interfaces, and you can pass classes, interfaces and primitives as type parameters.
BourgondAries
@BourgondAries
Yeah but if I have a class named
MyClass that takes a generic (interface) called Stuff, does my replacement need to inherit from Stuff's interface?
MyClass<Stuff=MyMathClass>
Clashsoft
@Clashsoft
Ah, I see. By default, you have unbounded Generics. But you can specify upper bounds: class MyGeneric[T <: Some[T]
Now the type parameters have to inherit from the class / interface Some.
BourgondAries
@BourgondAries
So it's more powerful than Java generics, and more like C++ templates?
Clashsoft
@Clashsoft
Java generics lets you do that as well: class MyGeneric<T extends Some<T>>
BourgondAries
@BourgondAries
No. There is a requirement to extend something, and if you extend Object, then members can't be revealed.
Clashsoft
@Clashsoft

You can also specify no bounds at all:

class MyGeneric<T>

In this case, the implicit bound is java.lang.Object

If you bounded parameter, you can access all fields and methods of the bound:
class MyGeneric<T extends Printable>
{
    public void foo(T value) { value.print() }
}
BourgondAries
@BourgondAries
What if I want to access anything?
public <T> Something foo(T t) { return t.getSomethingArbitrary(); }
Clashsoft
@Clashsoft
That seems like it violates static type safety
BourgondAries
@BourgondAries

The compiler can check it.
foo<MyType>(obj);

If MyType doesn't support the method, compilation fails.

This is what C++ does
Clashsoft
@Clashsoft
But then the compiler always needs access to the source code and has significantly more work to do. What if I have like 5 nested generic calls?
BourgondAries
@BourgondAries
If you don't, the runtime has more work to do via virtual calls.
Compile time is virtually free.
Clashsoft
@Clashsoft
Trade-offs have to be made. And that example seems extremely hard to understand. What if you want to refactor that method to a different name? How does the compiler know about it? These are essentially the problems of dynamic / duck typing
BourgondAries
@BourgondAries
If you refactor it you just change it in the instantiation of the class as well as the usage in the method.
The compiler just gets the input class, which is a table of methods and members.
Clashsoft
@Clashsoft
That requires you to know every single place in which the method is referenced.
BourgondAries
@BourgondAries
How so?
Clashsoft
@Clashsoft
If you have to manually change the name everywhere?
BourgondAries
@BourgondAries
The thing is you provide a class as a template, the template specifies that it requires that template to have an API as defined by its usage. You thereby separate the template class from the actual input template.
Clashsoft
@Clashsoft
I know how templates work, but I fail to see how they can be refactored in a sane way.
BourgondAries
@BourgondAries
It's just like refactoring an API, it won't be automatic, but is a change of names your only concern?
Clashsoft
@Clashsoft
When I want to rename a method, I use some key combination, type the new name, and every single textual reference gets updated and everything works exactly the same as before.
No, my second concern is that it might be hard to figure out where these magic methods come from.
BourgondAries
@BourgondAries
Well they're specified in the template parameter.
public <X> void f(X x) {
    x.magic();  // x is of type X, X is a template, hence, magic is given by another class.
}
Clashsoft
@Clashsoft
Yeah, but you don't know which one at declaration site.
Clashsoft
@Clashsoft
You can't quickly view documentation, you can't refactor, you can't use autocomplete, ...
This seems like a very, very bad design idea.
(in strongly typed languages)
BourgondAries
@BourgondAries
That's true. For my language I'm implementing a template-checker so you can check what the minimal interface needs to be like from the templated class itself.
Clashsoft
@Clashsoft
So you use some kind of structural typing?
BourgondAries
@BourgondAries
In templates; you could say yes.
So long the necessary methods/members are there for templates, and the unit tests succeed (checking the semantics of the template), the code will compile. This won't work for method arguments. These are strictly typed.
Clashsoft
@Clashsoft
I think I finally figured out how to get rid of operator resolution in the Parser
And, as predicted, it required whitespace-significant prefix and postfix operators.
But it turns out they work surprisingly well; I didn't have to change a single bit in existing Dyvil files.