Skip to content

Commit

Permalink
Fix/simplify alias
Browse files Browse the repository at this point in the history
  • Loading branch information
gilch committed Dec 24, 2023
1 parent cac0003 commit 995a92b
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions src/hissp/macros.lissp
Original file line number Diff line number Diff line change
Expand Up @@ -823,32 +823,23 @@ Hidden doctest adds bundled macros for REPL-consistent behavior.
;; >>> # hissp.._macro_.alias
;; ... # hissp.macros.._macro_.defmacro
;; ... # hissp.macros.._macro_.let
;; ... (lambda _Qz2D5FNHXZz_fn=(lambda _QzE4JATHEUz_first,*_QzE4JATHEUz_rest,**_QzE4JATHEUz_kwargs:(
;; ... (lambda _Qz2D5FNHXZz_fn=(lambda _QzE4JATHEUz_attr,*_QzE4JATHEUz_args,**_QzE4JATHEUz_kwargs:(
;; ... 'Aliases ``hissp.._macro_`` as ``HQzCOLON_#``.',
;; ... # hissp.macros.._macro_.ifQz_else
;; ... (lambda b,c,a:c()if b else a())(
;; ... _QzE4JATHEUz_rest,
;; ... _QzE4JATHEUz_args,
;; ... (lambda :
;; ... # hissp.macros.._macro_.let
;; ... (lambda _QzE4JATHEUz_rest=__import__('builtins').list(
;; ... _QzE4JATHEUz_rest):
;; ... __import__('builtins').getattr(
;; ... __import__('hissp')._macro_,
;; ... ('{}{}').format(
;; ... _QzE4JATHEUz_first,
;; ... # hissp.macros.._macro_.ifQz_else
;; ... (lambda b,c,a:c()if b else a())(
;; ... 'hissp.._macro_'.endswith(
;; ... '._macro_'),
;; ... (lambda :'QzHASH_'),
;; ... (lambda :('')))))(
;; ... _QzE4JATHEUz_rest.pop(),
;; ... *_QzE4JATHEUz_rest,
;; ... **_QzE4JATHEUz_kwargs))()),
;; ... __import__('builtins').getattr(
;; ... __import__('hissp')._macro_,
;; ... ('{}{}').format(
;; ... _QzE4JATHEUz_attr,
;; ... 'QzHASH_'))(
;; ... *_QzE4JATHEUz_args,
;; ... **_QzE4JATHEUz_kwargs)),
;; ... (lambda :
;; ... ('{}.{}').format(
;; ... 'hissp.._macro_',
;; ... _QzE4JATHEUz_first))))[-1]):(
;; ... _QzE4JATHEUz_attr))))[-1]):(
;; ... __import__('builtins').setattr(
;; ... _Qz2D5FNHXZz_fn,
;; ... '__doc__',
Expand Down Expand Up @@ -893,17 +884,14 @@ Hidden doctest adds bundled macros for REPL-consistent behavior.
;; See also: `prelude`, `attach`.
;;
`(defmacro ,(.format "{}{}" abbreviation '#)
($#first : :* $#rest :** $#kwargs)
($#attr : :* $#args :** $#kwargs)
',(.format "Aliases ``{}`` as ``{}#``." qualifier abbreviation)
(if-else $#rest
(let ($#rest (list $#rest))
((getattr ,qualifier (.format "{}{}"
$#first
(if-else (.endswith ',qualifier ','._macro_)
','#
"")))
(.pop $#rest) : :* $#rest :** $#kwargs))
(.format "{}.{}" ',qualifier $#first))))
(if-else $#args
((getattr ,qualifier ,(if-else (.endswith qualifier '._macro_)
`(.format "{}{}" ,'$#attr ','#)
'$#attr))
: :* $#args :** $#kwargs)
(.format "{}.{}" ',qualifier $#attr))))

(alias i itertools.)
(alias op operator.)
Expand Down

0 comments on commit 995a92b

Please sign in to comment.