Coder Social home page Coder Social logo

A better sintaxe about eo HOT 26 CLOSED

objectionary avatar objectionary commented on August 21, 2024
A better sintaxe

from eo.

Comments (26)

DronMDF avatar DronMDF commented on August 21, 2024 5

Drop semicolon - this is a good idea.
Only one expression per line.

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024 2

@mdbs99 why no semi-colons? won't it be difficult to parse this code?

We don't need it. See F#, GoLang, Python... is more elegant

I think it's better to stay as close to Java as possible. Or I'm wrong?

Maybe not, why? Let's do some different.
GoLang use the type after as Object Pascal.

@mdbs99 in your syntax I can't have a method with the name constructor, right?

@yegor256 yes, we can't.

from eo.

yegor256 avatar yegor256 commented on August 21, 2024 2

@mdbs99 hm... I think I agree (about non-Java syntax). Where did you get your syntax?

from eo.

yegor256 avatar yegor256 commented on August 21, 2024 1

@mdbs99 why this:

name(): String

instead of this:

String name();

I think it's better to stay as close to Java as possible. Or I'm wrong?

from eo.

vivekimsit avatar vivekimsit commented on August 21, 2024 1

@mdbs99 seriously I want the honest opinion about the syntax being discussed above like I would never like to review the code written above. At least the syntax shouldn't be completely alien.

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@mdbs99 why no semi-colons? won't it be difficult to parse this code?

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

Here an example of copy:

var dog = object Dog("Rex") { ... } 
var lucy = object Dog("Lucy") from dog

Now you have lucy, an object copied from dog (Rex) but name was initialized using Rex's constructor.

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@mdbs99 in your syntax I can't have a method with the name constructor, right?

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

How to use delegation (see comments here)

type Stream { serialize() }

var b64 = object Stream(d: String) {
  // implements base64
}

type Dog extends Run, Bark, Stream { 
  name(): String
  sit()
}
var dog = object Dog("Rex") {
  constructor (n: String) { var name = n }
  name(): String { print (name) }
  sit() { print ("sat") }
  compose {  
    run from r1 implements Run
    bark from b1 implements Bark
    stream from b64 implements Stream(name())
  }
}

print ("Dog in base 64: " +dog.stream.serialize())

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@yegor256
Everybody copy C++ or Java syntax. Let's move on.
A developer who loves Java won't like this new language, I suppose.
So, let's create a new language... a better one.

from eo.

vivekimsit avatar vivekimsit commented on August 21, 2024

we can take help from Scala too I like their idea of trait and object.

http://docs.scala-lang.org/tutorials/tour/classes.html

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@yegor256 nowhere, I invented when we talked on Gitter.

from eo.

akryvtsun avatar akryvtsun commented on August 21, 2024

@mdbs99 could you, pls, explaine this syntax

...
compose {  
    run from r1 implements Run
    bark from b1 implements Bark
    stream from b64 implements Stream(name())
}
...

E.g. here
run from r1 implements Run
what does this mean? What are run and r1?

from eo.

akryvtsun avatar akryvtsun commented on August 21, 2024

@mdbs99 also here

...
constructor (v: String) {
    var value = v
}
...

What is value? Is this local ctor variable or object field?

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@Englishman

run from r1 implements Run

This is a Object Pascal feature (but the syntax is different, see here).
Means you have a Object that could implement many interfaces, but you don't need to implement these methods, just delegate them for another objects.

what does this mean? What are run and r1?

So, in that syntax I've proposed run is a property that will receive an instance that implements the Interface Run, ie, the r1 object (declarated in first comment).

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@Englishman

What is value? Is this local ctor variable or object field?

Yes, looks ambiguous...
Maybe we can use @ like Ruby for all attributes, because is annoying to write this for attributes but not methods — an inconsistency, IMO.

EDIT:
Now I remembered what I had thought: All variables inside a ctor is an attribute.

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@mdbs99 I like the idea about @, here is the ticket: #10

from eo.

monsieurluge avatar monsieurluge commented on August 21, 2024

I like the def keyword instead of var. Sounds more object oriented to me.

And why not get rid of the equal sign when defining variables, and keep it only for comparisons ?

def name is String("Mattew")

return name = String("Johnny")

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@DronMDF I agree, we don't need semi-colons at all

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@monsieurluge check this out: #20

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@yegor256 I think this issue can be closed because people chose another syntax.
But, if we close this, I will start another issue to talk about composition to implement Types. What do you think?

from eo.

vivekimsit avatar vivekimsit commented on August 21, 2024

To be honest I think the syntax looks too verbose and too much indentation.

Int max(Int a, Int b):
  if:
    lessThan:
      a,
      b
    b,
    a

I am not a language designer but I would love to see something close to this:

if a lessThan b then b else a

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

@vivekimsit I've suggested to use brackets, at first, because I guess most here likes Java. But after I've talked to use end to delimit a block — like Ruby or Pascal (without begin).
I still think that using end is a better choice. That make possible to write as you said, in one line.

from eo.

mdbs99 avatar mdbs99 commented on August 21, 2024

I guess you talking about the syntax that use whitespaces, right?

from eo.

vivekimsit avatar vivekimsit commented on August 21, 2024
Int max(Int a, Int b):
  if:
    lessThan:
      a,
      b
    b,
    a

and

import org.eolang.cli
import org.eolang.printed
import org.eolang.string
cli:
  printed:
    string:
      "Hello, world!"

from eo.

yegor256 avatar yegor256 commented on August 21, 2024

@mdbs99 we have a new syntax now

from eo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.