No problem, in addition check out Lee's entmake functions, where you supply the arguments and the entity name is returned, so you can store it or manipulate it further.
Also the basic structures in LISP are lists and atoms, so its acceptable to work with a list of enames, rather than a selection set.
With vanilla LISP, you can obtain the set using entlast / entnext functions (without having the need to group them in a separate layer) :
(setq ListOfLineEnames
(
(lambda ( / object tmp eL )
(command "_.rectangle" "0,0" "10,10")
(command "_.explode" (setq object (entlast)))
(setq tmp object)
(while (setq tmp (entnext tmp))
(setq eL (cons tmp eL))
)
eL
)
)
)
(foreach line ListOfLineEnames
(entdel line)
; or do whatever you want here
)
Also you can create these objects "programatically", meaning wihtout any command calls. So you can store them instantly while creating.