Giter Site home page Giter Site logo

Comments (5)

dockimbel avatar dockimbel commented on May 14, 2024

This issue can be workaround by specifying a return value in 'myand definition. Currently the implementation requires that infix functions have a return type, I need to check the code to see if this dependency can be removed or if I need to add it to the specification draft.

from red.

meijeru avatar meijeru commented on May 14, 2024

That workaround has itself a problem: the infix function may be polymorphic! At least 'myand is, since it is a copy of 'and. Are you planning to allow more than one type in argument and return specs?

from red.

dockimbel avatar dockimbel commented on May 14, 2024

`myand' is part of an expression where it will be evaluated first (expressions are reduced from left to right reduction), so it requires parens on his right expression argument, else a compilation error will occur:

With parens:
17 myand (13 + 1), it is reduced to the prefix form: myand 17 + 13 1

Without parens:
17 myand 13 + 1, it is reduce to the prefix form: + myand 17 13 1

*** Compilation Error: return type missing in function: myand *** in: %tests/test.reds *** at: [myand 17 13 1 ]

from red.

meijeru avatar meijeru commented on May 14, 2024

I fail to see what is wrong with + myand 17 13 1 ! Since myand has two arguments, 17 and 13, it will yield an integer that can be added to 1 by +.

from red.

dockimbel avatar dockimbel commented on May 14, 2024

It is not allowed to yield any value without a proper [return:] declaration in the function specification block. In my examples, in both cases, I have used your function declaration (so without any [return:] declaration).

In the "with parens" example, 'myand doesn't need to return anything as it is the root of the expression, so the compiler let it pass. In the "without parens" example, 'myand needs to return a value to be used as argument for '+ operator, in contradiction to 'myand specification block, so the compiler raises an error.

from red.

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.