Subject: 24.3; json.el functions are recursive

From: [email-masked] ([email-masked])
Date: Tue, 10 Mar 2015 21:35:19 +0000

Feature request: rewrite `json.el' so that it doesn't use recursive
functions. Emacs doesn't support TCO, therefore invoking `json.el'
functions on huge data structures results in stack overflow.

For example, I created a ridiculously huge data structure using a
function from `dash.el':

(defvar a (-iterate (lambda (x) (cons x (list (list x)))) 1 5))

Now (json-encode lol) will result in exceeding `max-lisp-eval-depth'.

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.9)
 of 2014-06-06 on brownie, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
System Description:	Ubuntu 14.10

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_MONETARY: kk_KZ.UTF-8
  value of $LC_NUMERIC: kk_KZ.UTF-8
  value of $LC_TIME: kk_KZ.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Help

Minor modes in effect:
  shell-dirtrack-mode: t
  icomplete-mode: t
  global-hl-line-mode: t
  show-paren-mode: t
  ido-everywhere: t
  keyfreq-autosave-mode: t
  keyfreq-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  override-global-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Recent input:
M-i M-i ) M-H <return> M-p M-N M-N M-N M-N M-n C-M-SPC 
<backspace> <backspace> SPC n i l M-H <return> 1 SPC 
( 1 ) M-h <M-backspace> <M-backspace> M-H SPC 1 SPC 
<backspace> <backspace> ( 1 SPC ( 1 ) ) SPC ( 1 SPC 
( 1 SPC ( 1 ) ) ) M-h M-SPC M-H M-x c o n s SPC ( <backspace> 
M-h ( M-H 1 SPC ( l i s t SPC 1 ) ) <return> M-p M-N 
M-N M-N M-n M-i M-i M-i ( l i s t SPC M-H ) <return> 
M-p M-h M-p M-p M-N M-N M-p M-p M-p M-p M-p M-p M-p 
M-p M-p M-N M-N M-N M-N M-n ( l i s t SPC M-I M-i M-i 
) M-H <return> M-p M-h ( l a s t SPC M-H ) <return> 
M-p M-n M-n <backspace> 1 0 0 0 M-h ( s <backspace> 
d e f v a M-s s e t q SPC l o l SPC M-H ) <return> 
M-p M-h M-I M-i M-t M-s d e f v a <backspace> <backspace> 
c o n s t SPC l o l M-H <return> ( c a r SPC l o l 
) <return> M-: ( c a r SPC l o l ) <return> ( j s o 
n - e n d <backspace> c <tab> SPC l o l ) <return> 
M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u 
M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u M-u 
M-i M-e <help-echo> <down-mouse-1> <mouse-1> <help-echo> 
M-SPC M-H M-c M-r M-a b u <backspace> <backspace> e 
m a c - <backspace> s - b u <backspace> <backspace> 
r e p <tab> C-g C-g M-a r e p o r t <tab> <return>

Recent messages:
History item: 6
History item: 7
History item: 8
History item: 9
History item: 10
History item: 11
History item: 12
History item: 1 [3 times]
((((... ...) (...)) ((... ...))) (((... ...) (...))))
Mark set
Quit [2 times]

Load-path shadows:
~/.emacs.d/pymacs hides /home/sindikat/.emacs.d/elpa/pymacs-0.25/pymacs
/usr/share/emacs/24.3/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
~/.emacs.d/custom hides /usr/share/emacs/24.3/lisp/custom
/home/sindikat/.emacs.d/elpa/json-1.2/json hides /usr/share/emacs/24.3/lisp/json
/usr/share/emacs24/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.3/lisp/textmodes/ispell
/usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.3/lisp/textmodes/flyspell
/home/sindikat/.emacs.d/elpa/org-20150309/ob-keys hides /usr/share/emacs/24.3/lisp/org/ob-keys
/home/sindikat/.emacs.d/elpa/org-20150309/org-capture hides /usr/share/emacs/24.3/lisp/org/org-capture
/home/sindikat/.emacs.d/elpa/org-20150309/ob-java hides /usr/share/emacs/24.3/lisp/org/ob-java
/home/sindikat/.emacs.d/elpa/org-20150309/org-w3m hides /usr/share/emacs/24.3/lisp/org/org-w3m
/home/sindikat/.emacs.d/elpa/org-20150309/ob-exp hides /usr/share/emacs/24.3/lisp/org/ob-exp
/home/sindikat/.emacs.d/elpa/org-20150309/org-entities hides /usr/share/emacs/24.3/lisp/org/org-entities
/home/sindikat/.emacs.d/elpa/org-20150309/org-timer hides /usr/share/emacs/24.3/lisp/org/org-timer
/home/sindikat/.emacs.d/elpa/org-20150309/ob-haskell hides /usr/share/emacs/24.3/lisp/org/ob-haskell
/home/sindikat/.emacs.d/elpa/org-20150309/org-clock hides /usr/share/emacs/24.3/lisp/org/org-clock
/home/sindikat/.emacs.d/elpa/org-20150309/ob-scheme hides /usr/share/emacs/24.3/lisp/org/ob-scheme
/home/sindikat/.emacs.d/elpa/org-20150309/org-list hides /usr/share/emacs/24.3/lisp/org/org-list
/home/sindikat/.emacs.d/elpa/org-20150309/org-eshell hides /usr/share/emacs/24.3/lisp/org/org-eshell
/home/sindikat/.emacs.d/elpa/org-20150309/ob-awk hides /usr/share/emacs/24.3/lisp/org/ob-awk
/home/sindikat/.emacs.d/elpa/org-20150309/ob-sh hides /usr/share/emacs/24.3/lisp/org/ob-sh
/home/sindikat/.emacs.d/elpa/org-20150309/ob-ocaml hides /usr/share/emacs/24.3/lisp/org/ob-ocaml
/home/sindikat/.emacs.d/elpa/org-20150309/ob-fortran hides /usr/share/emacs/24.3/lisp/org/ob-fortran
/home/sindikat/.emacs.d/elpa/org-20150309/org-gnus hides /usr/share/emacs/24.3/lisp/org/org-gnus
/home/sindikat/.emacs.d/elpa/org-20150309/org-inlinetask hides /usr/share/emacs/24.3/lisp/org/org-inlinetask
/home/sindikat/.emacs.d/elpa/org-20150309/ob-lob hides /usr/share/emacs/24.3/lisp/org/ob-lob
/home/sindikat/.emacs.d/elpa/org-20150309/org-mouse hides /usr/share/emacs/24.3/lisp/org/org-mouse
/home/sindikat/.emacs.d/elpa/org-20150309/ob-lilypond hides /usr/share/emacs/24.3/lisp/org/ob-lilypond
/home/sindikat/.emacs.d/elpa/org-20150309/ob-dot hides /usr/share/emacs/24.3/lisp/org/ob-dot
/home/sindikat/.emacs.d/elpa/org-20150309/org-irc hides /usr/share/emacs/24.3/lisp/org/org-irc
/home/sindikat/.emacs.d/elpa/org-20150309/org-feed hides /usr/share/emacs/24.3/lisp/org/org-feed
/home/sindikat/.emacs.d/elpa/org-20150309/org-footnote hides /usr/share/emacs/24.3/lisp/org/org-footnote
/home/sindikat/.emacs.d/elpa/org-20150309/ob-org hides /usr/share/emacs/24.3/lisp/org/ob-org
/home/sindikat/.emacs.d/elpa/org-20150309/org-bibtex hides /usr/share/emacs/24.3/lisp/org/org-bibtex
/home/sindikat/.emacs.d/elpa/org-20150309/ob-scala hides /usr/share/emacs/24.3/lisp/org/ob-scala
/home/sindikat/.emacs.d/elpa/org-20150309/org-datetree hides /usr/share/emacs/24.3/lisp/org/org-datetree
/home/sindikat/.emacs.d/elpa/org-20150309/org-version hides /usr/share/emacs/24.3/lisp/org/org-version
/home/sindikat/.emacs.d/elpa/org-20150309/ob-clojure hides /usr/share/emacs/24.3/lisp/org/ob-clojure
/home/sindikat/.emacs.d/elpa/org-20150309/ob-sql hides /usr/share/emacs/24.3/lisp/org/ob-sql
/home/sindikat/.emacs.d/elpa/org-20150309/ob-table hides /usr/share/emacs/24.3/lisp/org/ob-table
/home/sindikat/.emacs.d/elpa/org-20150309/org-habit hides /usr/share/emacs/24.3/lisp/org/org-habit
/home/sindikat/.emacs.d/elpa/org-20150309/ob-sass hides /usr/share/emacs/24.3/lisp/org/ob-sass
/home/sindikat/.emacs.d/elpa/org-20150309/ob-tangle hides /usr/share/emacs/24.3/lisp/org/ob-tangle
/home/sindikat/.emacs.d/elpa/org-20150309/ob-maxima hides /usr/share/emacs/24.3/lisp/org/ob-maxima
/home/sindikat/.emacs.d/elpa/org-20150309/ob-lisp hides /usr/share/emacs/24.3/lisp/org/ob-lisp
/home/sindikat/.emacs.d/elpa/org-20150309/org-agenda hides /usr/share/emacs/24.3/lisp/org/org-agenda
/home/sindikat/.emacs.d/elpa/org-20150309/org-ctags hides /usr/share/emacs/24.3/lisp/org/org-ctags
/home/sindikat/.emacs.d/elpa/org-20150309/ob-picolisp hides /usr/share/emacs/24.3/lisp/org/ob-picolisp
/home/sindikat/.emacs.d/elpa/org-20150309/ob-ditaa hides /usr/share/emacs/24.3/lisp/org/ob-ditaa
/home/sindikat/.emacs.d/elpa/org-20150309/ob-ref hides /usr/share/emacs/24.3/lisp/org/ob-ref
/home/sindikat/.emacs.d/elpa/org-20150309/org-attach hides /usr/share/emacs/24.3/lisp/org/org-attach
/home/sindikat/.emacs.d/elpa/org-20150309/org-archive hides /usr/share/emacs/24.3/lisp/org/org-archive
/home/sindikat/.emacs.d/elpa/org-20150309/ob-asymptote hides /usr/share/emacs/24.3/lisp/org/ob-asymptote
/home/sindikat/.emacs.d/elpa/org-20150309/ob-js hides /usr/share/emacs/24.3/lisp/org/ob-js
/home/sindikat/.emacs.d/elpa/org-20150309/org-docview hides /usr/share/emacs/24.3/lisp/org/org-docview
/home/sindikat/.emacs.d/elpa/org-20150309/ob-python hides /usr/share/emacs/24.3/lisp/org/ob-python
/home/sindikat/.emacs.d/elpa/org-20150309/ob-ruby hides /usr/share/emacs/24.3/lisp/org/ob-ruby
/home/sindikat/.emacs.d/elpa/org-20150309/ob hides /usr/share/emacs/24.3/lisp/org/ob
/home/sindikat/.emacs.d/elpa/org-20150309/org-colview hides /usr/share/emacs/24.3/lisp/org/org-colview
/home/sindikat/.emacs.d/elpa/org-20150309/ob-css hides /usr/share/emacs/24.3/lisp/org/ob-css
/home/sindikat/.emacs.d/elpa/org-20150309/ob-calc hides /usr/share/emacs/24.3/lisp/org/ob-calc
/home/sindikat/.emacs.d/elpa/org-20150309/org-compat hides /usr/share/emacs/24.3/lisp/org/org-compat
/home/sindikat/.emacs.d/elpa/org-20150309/ob-matlab hides /usr/share/emacs/24.3/lisp/org/ob-matlab
/home/sindikat/.emacs.d/elpa/org-20150309/ob-eval hides /usr/share/emacs/24.3/lisp/org/ob-eval
/home/sindikat/.emacs.d/elpa/org-20150309/ob-emacs-lisp hides /usr/share/emacs/24.3/lisp/org/ob-emacs-lisp
/home/sindikat/.emacs.d/elpa/org-20150309/ob-mscgen hides /usr/share/emacs/24.3/lisp/org/ob-mscgen
/home/sindikat/.emacs.d/elpa/org-20150309/org-crypt hides /usr/share/emacs/24.3/lisp/org/org-crypt
/home/sindikat/.emacs.d/elpa/org-20150309/ob-screen hides /usr/share/emacs/24.3/lisp/org/ob-screen
/home/sindikat/.emacs.d/elpa/org-20150309/ob-ledger hides /usr/share/emacs/24.3/lisp/org/ob-ledger
/home/sindikat/.emacs.d/elpa/org-20150309/org-loaddefs hides /usr/share/emacs/24.3/lisp/org/org-loaddefs
/home/sindikat/.emacs.d/elpa/org-20150309/org-bbdb hides /usr/share/emacs/24.3/lisp/org/org-bbdb
/home/sindikat/.emacs.d/elpa/org-20150309/org-macs hides /usr/share/emacs/24.3/lisp/org/org-macs
/home/sindikat/.emacs.d/elpa/org-20150309/org-install hides /usr/share/emacs/24.3/lisp/org/org-install
/home/sindikat/.emacs.d/elpa/org-20150309/org-rmail hides /usr/share/emacs/24.3/lisp/org/org-rmail
/home/sindikat/.emacs.d/elpa/org-20150309/ob-plantuml hides /usr/share/emacs/24.3/lisp/org/ob-plantuml
/home/sindikat/.emacs.d/elpa/org-20150309/ob-sqlite hides /usr/share/emacs/24.3/lisp/org/ob-sqlite
/home/sindikat/.emacs.d/elpa/org-20150309/org hides /usr/share/emacs/24.3/lisp/org/org
/home/sindikat/.emacs.d/elpa/org-20150309/ob-shen hides /usr/share/emacs/24.3/lisp/org/ob-shen
/home/sindikat/.emacs.d/elpa/org-20150309/ob-R hides /usr/share/emacs/24.3/lisp/org/ob-R
/home/sindikat/.emacs.d/elpa/org-20150309/org-element hides /usr/share/emacs/24.3/lisp/org/org-element
/home/sindikat/.emacs.d/elpa/org-20150309/org-mobile hides /usr/share/emacs/24.3/lisp/org/org-mobile
/home/sindikat/.emacs.d/elpa/org-20150309/ob-gnuplot hides /usr/share/emacs/24.3/lisp/org/ob-gnuplot
/home/sindikat/.emacs.d/elpa/org-20150309/org-src hides /usr/share/emacs/24.3/lisp/org/org-src
/home/sindikat/.emacs.d/elpa/org-20150309/org-table hides /usr/share/emacs/24.3/lisp/org/org-table
/home/sindikat/.emacs.d/elpa/org-20150309/org-mhe hides /usr/share/emacs/24.3/lisp/org/org-mhe
/home/sindikat/.emacs.d/elpa/org-20150309/ob-io hides /usr/share/emacs/24.3/lisp/org/ob-io
/home/sindikat/.emacs.d/elpa/org-20150309/org-faces hides /usr/share/emacs/24.3/lisp/org/org-faces
/home/sindikat/.emacs.d/elpa/org-20150309/ob-perl hides /usr/share/emacs/24.3/lisp/org/ob-perl
/home/sindikat/.emacs.d/elpa/org-20150309/ob-C hides /usr/share/emacs/24.3/lisp/org/ob-C
/home/sindikat/.emacs.d/elpa/org-20150309/ob-octave hides /usr/share/emacs/24.3/lisp/org/ob-octave
/home/sindikat/.emacs.d/elpa/org-20150309/ob-comint hides /usr/share/emacs/24.3/lisp/org/ob-comint
/home/sindikat/.emacs.d/elpa/org-20150309/org-protocol hides /usr/share/emacs/24.3/lisp/org/org-protocol
/home/sindikat/.emacs.d/elpa/org-20150309/org-info hides /usr/share/emacs/24.3/lisp/org/org-info
/home/sindikat/.emacs.d/elpa/org-20150309/org-plot hides /usr/share/emacs/24.3/lisp/org/org-plot
/home/sindikat/.emacs.d/elpa/org-20150309/ob-latex hides /usr/share/emacs/24.3/lisp/org/ob-latex
/home/sindikat/.emacs.d/elpa/org-20150309/org-pcomplete hides /usr/share/emacs/24.3/lisp/org/org-pcomplete
/home/sindikat/.emacs.d/elpa/org-20150309/org-id hides /usr/share/emacs/24.3/lisp/org/org-id
/home/sindikat/.emacs.d/elpa/org-20150309/org-indent hides /usr/share/emacs/24.3/lisp/org/org-indent
~/.emacs.d/secrets hides /usr/share/emacs/24.3/lisp/net/secrets

Features:
(shadow sort mail-extr emacsbug js imenu cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs shell
misearch multi-isearch thingatpt face-remap org-w3m org-wl org-vm
org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs org-html org-exp
org-exp-blocks org-info org-gnus org-docview doc-view jka-compr
image-mode dired org-bibtex bibtex org-bbdb bookmark org-element debug
json help-mode ielm pp gnutls network-stream starttls tls pop3 nndraft
nnmh nnfolder nnml gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime smime dig
mailcap nntp gnus-cache gnus-sum nnoo gnus-group gnus-undo nnmail
mail-source gnus-start gnus-spec gnus-int gnus-range message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus-win gnus gnus-ems nnheader wid-edit server
eldoc flyspell ispell icomplete hl-line paren ido keyfreq uniquify
warnings advice help-fns advice-preload cl-macs gv cl-lib org-id
org-mobile org-agenda org org-macro org-footnote org-pcomplete pcomplete
org-list org-faces org-entities noutline outline org-version ob-scheme
geiser ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src
ob-keys ob-comint comint ansi-color ring ob-core ob-eval org-compat
org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs smtpmail auth-source eieio byte-opt bytecomp byte-compile
cconv gnus-util time-date password-cache sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils wombat-theme undo-tree diff
suspend app f s ucs-normalize dash-functional dash moderne-mode bind-key
easy-mmode color-theme-autoloads dash-functional-autoloads
ergoemacs-mode-autoloads f-autoloads dash-autoloads geiser-autoloads
ghc-autoloads ghci-completion-autoloads graphviz-dot-mode-autoloads
haskell-mode-autoloads edmacro kmacro ht-autoloads json-autoloads
markdown-mode-autoloads monokai-theme-autoloads org-autoloads
pymacs-autoloads request-autoloads rust-mode-autoloads s-autoloads
slime-autoloads info easymenu ttl-mode-autoloads undo-tree-autoloads
unidecode-autoloads finder-inf use-package-autoloads diminish-autoloads
bind-key-autoloads package tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)