Giter Site home page Giter Site logo

wrenpp / macros about wren HOT 3 CLOSED

wren-lang avatar wren-lang commented on July 28, 2024
wrenpp / macros

from wren.

Comments (3)

kmarekspartz avatar kmarekspartz commented on July 28, 2024

Here's one thing macros could sugar away: #79 (comment)

from wren.

munificent avatar munificent commented on July 28, 2024

This is a tricky one. I've spent a lot of time toying with macro systems and with the general idea of making a language "extensible" for various definitions of that. See 1, 2, 3, and 4.

If I were trying to make a big feature-full language (which is what Magpie is to a greater degree) I'd definitely be interested in this. But, I have two thoughts:

  1. When I played with making Magpie extensible, I found it wasn't actually that useful or usable to do so. Maybe it's a failure of imagination on my part, but I found few really compelling use cases for macros or syntax extension, and even those use cases were kind of a pain.
  2. They add a lot of complexity to the system. With Wren, I'm trying really really hard to keep it tiny. I think we may have a chance to make Wren a language that has real users, but the most viable path for that is as a minimal, narrowly-focused embeddable scripting language.

When I played with macros, I found the most common use case was that I wanted to define something "function-like" that could conditionally evaluate one of its arguments. So, with Wren, I just optimized exactly for that case. For example, let's say you want to have a kind of flow control construct that executes its body only on Tuesdays. In other languages, you'd need a macro. In Wren, it's just a block argument:

Calendar.onTuesday {
  ...
}

It has the look of something pretty seamlessly added to the language, and has the controlled lazy evaluation you want, but doesn't require the weight of a macro system. It's just a closure.

For reference, Smalltalk is considered one of the world's most "metaprogrammable" languages, and it doesn't have macros. It just uses blocks for everything. I want to see if we can do the same in Wren.

Does that make sense?

from wren.

kmarekspartz avatar kmarekspartz commented on July 28, 2024

Yes, I agree completely with regard to end-user macros. I'm not suggesting
exposing macros to users of wren, but to simplify implementation of things
like modules. Hence why I called this ticket wrenpp first. ;)

I may play around with something like this after #88.

On Thursday, January 8, 2015, Bob Nystrom [email protected] wrote:

Closed #90 #90.


Reply to this email directly or view it on GitHub
#90 (comment).

from wren.

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.