by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 13 12:24

    Clashsoft on master

    Update Gradle Wrapper to v6.5 (compare)

  • Jun 01 22:01

    Clashsoft on master

    Use Dyvil-Gradle v0.5.0 (compare)

  • Jun 01 21:50

    Clashsoft on master

    Add version task to all projects Fail bintrayUpload tasks if DYV… Restructure Gradle build scripts and 5 more (compare)

  • May 29 23:42

    Clashsoft on master

    Update bootstrap dependencies Fix compound assignment operato… Release v0.47.1 Compiler v0.47… and 1 more (compare)

  • May 29 23:42

    Clashsoft on bugfix

    (compare)

  • May 29 23:39

    Clashsoft on bugfix

    Fix compound assignment operato… Release v0.47.1 Compiler v0.47… Update bootstrap dependencies (compare)

  • May 29 23:01

    Clashsoft on bugfix

    Update bootstrap dependencies (compare)

  • May 29 22:39

    Clashsoft on develop

    (compare)

  • May 29 22:38

    Clashsoft on develop

    Release v0.47.0 Library v0.47.… (compare)

  • May 29 21:43

    Clashsoft on develop

    Fix String.apply(sharing:) in U… (compare)

  • May 29 21:33

    Clashsoft on develop

    Deprecate some reflection metho… Remove ReflectUtils.JAVA_LANG_A… Remove Try it Out section from … and 3 more (compare)

  • May 29 21:00
    Clashsoft demilestoned #516
  • May 29 21:00
    Clashsoft demilestoned #507
  • May 29 21:00
    Clashsoft demilestoned #506
  • May 29 21:00
    Clashsoft demilestoned #496
  • May 29 21:00
    Clashsoft demilestoned #487
  • May 29 21:00
    Clashsoft demilestoned #473
  • May 29 21:00
    Clashsoft demilestoned #472
  • May 29 21:00
    Clashsoft demilestoned #432
  • May 09 20:47
    Clashsoft closed #393
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.