Giter Club home page Giter Club logo

disp's People

Contributors

toumorokoshi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

stjordanis

disp's Issues

How to declare functions (anonymous and named)

Right now, there's a syntactical purity to the declaration of functions. one can do:

let foo (fn [arg] [
  (print "foo") 
  (print arg)
])

Effectively defining an anonymous function, then assigning it to foo. However, this syntax is a little cumbersome, because it requires the use of the bracket / parens in the function body.

A better looking function declaration could look like:

fn foo [args]
	print "foo"
	print arg

This looks a lot more like a declaration in Python: easy to read. However, this introduces a secondary way to declare such a function, which might make it harder for automated refactoring tools to detect and fix.

The automated refactoring might be a moot point anyway, because macros are effectively a re-expression of syntax and automated tools need to deal with that somehow.

Another alternative is to add a indentation rule that allows for a nested call to still use the no-expression rule. Something like:

let foo fn [args] 
  print "foo"
  print arg

This currently won't work because one cannot disambiguate between what is an argument to the fn function, vs the let declaration of the foo. I'm not a fan of introducing that, as it then requires the reader to know how many arguments an expression takes to understand what the above statement is doing (I have to know "let" takes three arguments to know that the final indented list is consumed by the fn declaration instead.

Does anyone have thoughts on this?

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.