Re: [racket-users] [racket users] %app question

2020-08-14 Thread Kevin Forchione


> On Aug 13, 2020, at 1:05 PM, Jens Axel Søgaard  wrote:
> 
> Den tor. 13. aug. 2020 kl. 21.55 skrev Kevin Forchione  >:
> Hi guys,
> 
> In Bracket [1] used your idea to produce s-expression, if the first argument
> of #%app isn't a function:
> 
> ; In the BRACKET language an application of
>   ; a non-function evaluates to an expression.
>   (define-syntax (sym-app stx)
> (syntax-case stx ()
>   [(_ op arg ...)
>(quasisyntax/loc stx
>  (let ([o op])
>(if (procedure? o)
>#,(syntax/loc stx (#%app o arg ...))
>(if (holdable? o)
>(cons o '(arg ...))
>(cons o (list arg ...))]))
> 
> There is an additional wrinkle - if a function is "holdable" it "holds" 
> (postpones) the 
> evaluation of its arguments. This can simply we be removed, if you don't need 
> it.
> 
> More details here:
> 
> https://github.com/soegaard/bracket/blob/master/bracket/bracket.rkt#L80 
> 
Thanks! With a little modification that does the trick! 

Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1358F277-7B1F-4C25-B791-96F70807F641%40gmail.com.


Re: [racket-users] [racket users] %app question

2020-08-13 Thread Jens Axel Søgaard
Den tor. 13. aug. 2020 kl. 21.55 skrev Kevin Forchione :

> Hi guys,
>
> Pollen makes use of something like this:
>
> (require syntax/parse/define)
>
> (define-simple-macro (#%top . x) 'x)
>
>
> and it comes in handy in some of my projects. But I’m wondering if there’s
> an equivalent for redirecting an application that hasn’t been defined?
>
> In other words, if foo is not a procedure then (foo 1 2 3) would redirect
> to (do-this foo 1 2 3) where do-this is defined?
>
> Any help is appreciated.
>

Hi Kevin,

In Bracket [1] used your idea to produce s-expression, if the first argument
of #%app isn't a function:

; In the BRACKET language an application of
  ; a non-function evaluates to an expression.
  (define-syntax (sym-app stx)
(syntax-case stx ()
  [(_ op arg ...)
   (quasisyntax/loc stx
 (let ([o op])
   (if (procedure? o)
   #,(syntax/loc stx (#%app o arg ...))
   (if (holdable? o)
   (cons o '(arg ...))
   (cons o (list arg ...))]))

There is an additional wrinkle - if a function is "holdable" it "holds"
(postpones) the
evaluation of its arguments. This can simply we be removed, if you don't
need it.

More details here:

https://github.com/soegaard/bracket/blob/master/bracket/bracket.rkt#L80


/Jens Axel
https://racket-stories.com

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABefVgxOx-v%2BZTMGB2tzxmrvb0PamAs4J%3Dg0ovBMTJT8D1bosw%40mail.gmail.com.


[racket-users] [racket users] %app question

2020-08-13 Thread Kevin Forchione
Hi guys,

Pollen makes use of something like this:

(require syntax/parse/define)

(define-simple-macro (#%top . x) 'x)


and it comes in handy in some of my projects. But I’m wondering if there’s an 
equivalent for redirecting an application that hasn’t been defined? 

In other words, if foo is not a procedure then (foo 1 2 3) would redirect to 
(do-this foo 1 2 3) where do-this is defined?

Any help is appreciated. 

Thanks!

Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/B7AAB6F2-9BBB-4C81-B29F-4B29B6F687D1%40gmail.com.