15

Is it possible to call a Common Lisp function in iOS?

If so, is it possible create it in a dynamic library?

Paulo Tomé
  • 1,910
  • 3
  • 18
  • 27
Egil
  • 165
  • 1
  • 5
  • Most answers here are outdated. It is not clear if the product mentioned still work, still produce linkable code which can actually be used in production: LLVM, arm64, bit compiling. Latest information on MOCL, which looks promising, is one year old. – Michele Giuseppe Fadda Nov 12 '15 at 11:37

6 Answers6

8

It depends on what you mean by calling a CL function, but most likely ECL will be your shortest path. Start here, as there is a patch for ECL to better accommodate iOS: http://funcall.posterous.com/tag/iphone

ECL generates C code, so you should be in safe territory with Apple's shifting policies.

Daniel
  • 188
  • 6
  • 1
    "Posterous Spaces is no longer available" :\ – Olie Jul 24 '13 at 17:54
  • @Olie http://web.archive.org/web/20130323055046/http://funcall.posterous.com/tag/iphone ; links to https://github.com/kriyative/ecl-iphone-builder/tree/elf and https://github.com/kriyative/ecl-iphone-builder/tree/dragon and http://mclide.in-progress.com/ . – Will Ness Aug 09 '13 at 18:36
  • Not relevant anymore for iOS. ECL patches used to support up to XCode 4.3 . Now Xcode requires LLVM, arm64 and both frameworks and static libraries need to be compiled with Bitcompile enabled. Current version of Xcode is 7.1 . – Michele Giuseppe Fadda Nov 12 '15 at 11:53
4

Have you tried MOCL?

According to the website "mocl is a highly optimizing CL implementation, delivering tight native code via LLVM/Clang".

Maybe you can create a dynamic library, though it is designed for use the other way around.

quasi
  • 41
  • 4
  • 5
    $199 Standard License, $1299 Enterprise – Mike Ivanov Sep 20 '13 at 17:07
  • 2
    mocl (what you call "Common Lisp for iOS and Android") does, in fact, allow you to export your CL functions such that they can be called from Obj-C or Swift. – masukomi Jul 13 '14 at 17:19
  • 1
    Does anybody know the CURRENT STATUS of MOCL? Is it being actively developed? Does it support newest LLVM bit compiling inside XCode ? Latest available info is now one year old... Do you have any news? – Michele Giuseppe Fadda Nov 12 '15 at 08:18
  • 1
    It appears to be supported, generates ARM64 as well. It is only a static subset of CL: no macros outside "compile time", no eval. – Michele Giuseppe Fadda Nov 13 '15 at 11:26
  • If you are looking for Open Source, MOCL is a no go, way too expensive. – kisai Feb 22 '19 at 09:00
  • I am surprised why they will not give away a free copy for non-commercial use. Without a developer community who likes it or who can take it ahead for commercial use, how are they going to get critical mass? – quasi Mar 20 '20 at 12:48
3

Clozure Common Lisp (CCL) runs in Linux on the ARM, and Gary Byers long ago made an experimental iPhone version, but it would only run on a jail-broken iPhone. The problem is that the CCL compiler writes executable code, but iOS out-of-the-box does not allow a writable page to be made executable, so you can't ever RUN that code.

We've had discussions about putting the code that ships with an iOS app be in a read-only code section, and adding a byte-code compiler, so that code created at run-time can be fairly quickly interpreted, but nobody has offered to fund that project, so it hasn't gotten done.

You might think that we could just interpret code created at run-time, but the current CCL "interpreter" compiles non-trivial code before executing it.

MOCL is probably your best option to write code callable from other apps, but that's only a guess, since I haven't used it.

1

You could use Gambit Scheme or Clozure Common Lisp, both are able to interface with Cocoa, the first because it generates C and the latter because there is a bridge from Clozure to Cocoa. Do a google search about it and you will find a few things.

m7d
  • 736
  • 6
  • 18
  • 3
    I did a couple google searches and I don't see how either of these is going to help. Gambit is a different programming language. Clozure doesn't have a Darwin/ARM port (closest ports are Darwin-x86 and Linux-ARM). – Ken Jan 31 '12 at 22:29
  • Gambit looks promising on paper, but it does not produce C sources which can be compiled within current Xcode (7.1) anymore. There appears to be some partial attempt at supporting LLVM. In its current status it is unusable. Clozure supports Objective C binding, but AFAIK it never worked on iOS. – Michele Giuseppe Fadda Nov 12 '15 at 11:58
1

You might want to keep an eye on this (new) project. It will be publicly available during October 2019: EQL5 iOS EQL5 iOS libs

user644348
  • 33
  • 3
0

There also exists Mobile Common Lisp1

PuercoPop
  • 6,707
  • 4
  • 30
  • 40