Giter Site home page Giter Site logo

User defined operators about qtspecs HOT 5 CLOSED

MarkNicholls avatar MarkNicholls commented on August 17, 2024
User defined operators

from qtspecs.

Comments (5)

michaelhkay avatar michaelhkay commented on August 17, 2024

I don't see that a syntax like that offers any significant benefits over our current

a => concatPrint(b)

What does Haskell do about operator precedence?

from qtspecs.

MarkNicholls avatar MarkNicholls commented on August 17, 2024

actually the => observations is pretty relevant, I don't especially use it (as its a tad contrary to my intuition/indoctrination elsewhere).

but lets carry on a tiny bit more (though i suspect you've undermined the motivation enough already)

so you can do this (and use it as a use case)

ghci> pure (+) <*> Just 3 <*> Just 5
Just 8

so here we're taking the normal operator + and then adding 2 maybe int s

(this sort of thing is only really useful (to me) if its targeted as a specific domain, not as a general style - though others will vehemently disagree)

so in XPath world thats (something like - don't take this too literally)

pure((+)) => maybe:apply(maybe:some(3)) => maybe:apply(maybe:some(5))

ew....though what I'm suggesting isn't much better.

pure((+)) 'maybe:apply' maybe:some(3) 'maybe:apply' maybe:some(5)

backtick operators have fixed precedence and are left associative.

tbh, I don't think my suggestion is really powerful enough to make my expressions 'elegant',

I was wondering if there was an easy preprocessing of the expression that could be done that would introduce user defined expressions into the language without too much cost.

But I'm doubting if there is much benefit.

I'll try using => and see how far it gets me.

from qtspecs.

MarkNicholls avatar MarkNicholls commented on August 17, 2024

closing, I think this is premature without me trynig out '=>' more

from qtspecs.

michaelhkay avatar michaelhkay commented on August 17, 2024

I'm not reopening the issue because it's not a serious proposal, but a bit of fun would be to allow all Unicode non-ASCII math symbols such as ≈ to be used as function names and possibly as binary operators, e.g.

declare %precedence(6) function ≈ ($x as xs:numeric, $y as xs:numeric) as xs:boolean {
    return abs($x - $y)  lt 1e-9
}

from qtspecs.

MarkNicholls avatar MarkNicholls commented on August 17, 2024

from qtspecs.

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.