GithubHelp home page GithubHelp logo

Alternate syntax for objects? about l HOT 1 CLOSED

brendanberg avatar brendanberg commented on June 3, 2024
Alternate syntax for objects?

from l.

Comments (1)

brendanberg avatar brendanberg commented on June 3, 2024

The latest design spec for the language introduces user-definable record types. Once defined, a record is constructed using standard call semantics to set internal properties either by position or by name.

Point << Integer x, Integer y >>

# Record constructors can set properties by position or by name:
p1 :: Point(5, 2)
p2 :: Point(x: 8, y: 6)

# Property access uses dot notation:
console ! (write: p1.x)
console ! (write: p1.y)

# Methods may be defined on any type using the following syntax:
Point p (distanceTo: Point q) -> {
    ( (p.x - q.x) ** 2 + (p.y - q.y) ** 2 )(.sqrt)
}

# And called like this:
d :: p1(distanceTo:p2) # `d` is 5.0

from l.

Related Issues (19)

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.