[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Prevent inlining

From: Stefan Israelsson Tampe
Subject: Prevent inlining
Date: Wed, 12 Feb 2020 18:44:31 +0100

Hi all,

Current guile inlines even variables exposed in the module interface, and I
understand that we must live with that and code around it. So here is a few
tips how to mitigate it.

The simplest way is to put this definition in a module:
(define-module (syntax not-inline)
  #:export (not-inline))

     (define (not-inline x) x))
  ((or (guile-2.0 guile-2.2)
     (define-syntax-rule (not-inline x) x)))

And then in another module do,

(use-modules (syntax not-inline))
(define variable (not-inline 12))
(define function (not-inline (lambda () ...)))

This is also an option (not perfect but you get the gist)

(define-module (syntax define-not-inlinable)
   #:use-module (syntax not-inline)
   #:export (inline define lambda  define* lambda* define-values)
(define inline (lambda (x) x))
(define-syntax define
   (syntax-rules (inline)
      ((define (f . x) . code)
       (define f (not-inline (lambda x . code)))
      ((define f (inline x))
       (define f x))
      ((define f x)
       (define f (not-inlinable x))))
using this module will make all usual define not inlineable and to enable
inlining you would
explicitly ask for it like

(define f (inline (lambda (x) (+ x 10))))

If there is a need for this I can write the modules and expose it on the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]