mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-05 23:20:19 +00:00
1 line
9.8 KiB
JSON
1 line
9.8 KiB
JSON
[{"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165694.1134641, "message": "(And using gensyms where appropriate, of course)", "group_id": 9739, "id": 1017380}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305165714.3712101, "message": "What would you like apply called on a macro to do?", "group_id": 9739, "id": 1017382}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165777.119339, "message": "Basically, it's running a macro and returning a result at runtime. I don't see many other ways to interpret using apply on a macro.", "group_id": 9739, "id": 1017389}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305166442.695359, "message": "That would suggest going in the direction of having apply just call the macro's expansion function.", "group_id": 9739, "id": 1017522}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165356.9543321, "message": "By the way, with my recent change, I made it so when you call something in functional position, it tries to coerce it to an fn. I think you can write a coercion rule that takes a macro, and then returns a function. This would allow apply to work on macros, I believe.", "group_id": 9739, "id": 1017314}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165743.883311, "message": "It should do the same thing as (eval `(my-mac ,@foo)) where my-mac is a macro, and foo is a list.", "group_id": 9739, "id": 1017385}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305166030.8019691, "message": "Yes, it does allow a macro to expand into \"my macro bar\", instead of whatever bar the user happens to have in their environment. I tend to use \"hygiene\" for macro systems that avoid collisions automatically, but it is a hygienic method in the sense that it does allow collisions to be avoided.", "group_id": 9739, "id": 1017434}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165290.0907121, "message": "Recently, ar was changed so that you could place macro values into functional position, which allowed for hygienic macros (I think). Also, this works: (eval `(in ,@foo)) which is the equivalent of (apply in foo) So... why doesn't apply work on macros, again?", "group_id": 9739, "id": 1017299}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165676.1277349, "message": "But if a macro unquotes everything, that would be effectively like macros with lexical scope, right?", "group_id": 9739, "id": 1017378}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305166095.0736091, "message": "I did say \"allowed for hygiene\" rather than \"encourages hygiene\" :P I agree that if you want hygienic macros, Arc-style macros make it clunky and difficult. Possible, but difficult.", "group_id": 9739, "id": 1017448}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305165614.22732, "message": "It didn't allow for hygienic macros, but it did allow macros to expand into macro values as well as symbols.", "group_id": 9739, "id": 1017363}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305165950.340028, "message": "Oh, by the way? You know how I said you could write a coerce rule? I did. It works. Apply works on macros now. But only if you manually coerce them to an fn. Now to make it work automatically...", "group_id": 9739, "id": 1017414}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305166151.1034801, "message": "Using apply on a macro could call the macro's expansion function without also calling eval. (I don't know if that would be useful, just another way to interpret using apply on a macro).", "group_id": 9739, "id": 1017460}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305166248.192018, "message": "Yes, but that's what macex does. So if you want that behavior, you just use macex. So you could use (apply macex:my-mac foo)", "group_id": 9739, "id": 1017478}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305166337.158565, "message": "By the way, I'll note that the \"ideal\" behavior for calling apply on macros should probably be whatever would work good with extend. Extend calls apply, and it would be nice if you could use extend on macros as well as functions.", "group_id": 9739, "id": 1017493}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305166508.3593359, "message": "Which is also interesting from the point of view of http://arclanguage.org/item?id=14560, since a \"macro\" could then simply be a function tagged with a \"macro\" label that the Arc compiler would pay attention, but the runtime would just treat it like any other function.", "group_id": 9739, "id": 1017537}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305166524.00542, "message": "/pay attention to/", "group_id": 9739, "id": 1017544}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305166643.520839, "message": "By the way, in case consistency matters, if foo is a function, then calling (foo 1 2 3) is equivalent to (apply foo '(1 2 3)) So an argument-from-consistency would suggest that the same should hold, even if foo is a macro. Whether we care about that kind of consistency is a different matter.\n\nI'll also note, that once I can get this working, you'll be able to customize the behavior of using apply on macros, just by extending coerce.", "group_id": 9739, "id": 1017568}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305166668.40763, "message": "(Okay, see, that's a bug. I still don't know what causes it. Weird.)", "group_id": 9739, "id": 1017584}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305167001.5496609, "message": "(You'd have to ask the Convore folks; I just started using Convore myself...)\n\nI don't know of any way to make (apply foo '(1 2 3)) to be actually equivalent to (foo 1 2 3) when foo is a macro, short of making Arc a pure interpreter and implementing first class macros. Calling eval on the macro expansion sort of does it but not really... I'd like to see some examples of it actually being useful before making it the default.", "group_id": 9739, "id": 1017706}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305168905.034162, "message": "The most obvious limitation is that (foo ...) can expand into something that uses lexical variables from its surrounding scope while eval can't. Which isn't to say that having calling apply on a macro be a shorthand for calling eval on the macro expansion might not be useful, merely that it's not equivalent.\n\n\"Useful\" means \"someone is using it\". So demonstrating that something is useful is actually usually pretty easy: just give an example of how you are using it :)", "group_id": 9739, "id": 1018212}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305169428.6646359, "message": "Well, using apply on \"in\" is nice, even though I know the \"some\" function exists, if you're building up the arg list dynamically, then using apply just makes sense. Another obvious example is extending a macro.", "group_id": 9739, "id": 1018281}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305168345.2523279, "message": "Um, but I just did it. Right now. It works. Unless you know of a situation where (apply foo ...) is actually distinguishable from (foo ...) with regard to macros.", "group_id": 9739, "id": 1018160}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305168734.4363301, "message": "Oh and by the way, it works fine when you manually coerce it, like (apply (coerce in 'fn) '(a a b c)) but not if you just use plain-old apply. The reason for that is because ar doesn't have access to the current version of coerce... so it's the same problem I discussed over in the other thread.", "group_id": 9739, "id": 1018189}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305168420.0628729, "message": "As for usefulness... well, I doubt I can convince you, but I've wanted to use apply on a macro at least a few times, and was confused when I couldn't, then annoyed. So I made sure that using apply does work on macros in Arubic/Python.", "group_id": 9739, "id": 1018167}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305168776.136503, "message": "The hack you described with passing an additional argument works most of the time, but not at the top level. If we can fix that, then apply should work just fine on macros.", "group_id": 9739, "id": 1018195}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305168837.4962521, "message": "Er.. the example should be (apply (coerce in 'fn) '(1 1 2 3))", "group_id": 9739, "id": 1018207}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305173285.1319301, "message": "Okay, I got apply on macros working. I also moved ar-apply (and some other stuff...) out of ar.ss so now there's no more need for the extra parameter, and I was able to get rid of the extra function creation/destruction stuff I set up earlier. So it should be just as fast as before, or at least pretty close.\n\nAnd yeah, you're right. It can't see outer variables in the scope. I wrote a test for it, so we can see if/when we fix that.", "group_id": 9739, "id": 1019477}, {"user_id": 32737, "stars": [], "topic_id": 34871, "date_created": 1305178213.1344049, "message": "By the way, if I set up a current-env implicit variable, I'm pretty sure I can make applying a macro work in the current lexical scope. Then (foo 1 2 3) and (apply foo '(1 2 3)) would be equivalent, right?", "group_id": 9739, "id": 1020384}, {"user_id": 25438, "stars": [], "topic_id": 34871, "date_created": 1305178800.212678, "message": "I don't think you'll be able to do that because the env is a compile time data structure and apply happens at runtime, but I perhaps I'll be surprised :)", "group_id": 9739, "id": 1020513}] |