Where to Put Macros?

12 views
Skip to first unread message

Kevin Meredith

unread,
Apr 29, 2015, 10:11:10 AM4/29/15
to spire...@googlegroups.com
I see at least two folders that might be appropriate homes for macros:
  • core/src/main/scala/spire/macros
  • macros/
From running into a compile-time error:

[error] ... macro implementation not found: apply
[error] (the most common reason for that is that you cannot use macro implementations in the same compilation run that define
s them)

I read in this answer (http://stackoverflow.com/questions/17150112/implement-abstract-methods-with-a-def-macro) that macros require a separate compilation step.

From looking at project/Build.scala, I'm guessing the macros should go into the macros/ folder.

Could you please let me know the difference between the two folders?

Thanks

Tom Switzer

unread,
Apr 29, 2015, 2:15:41 PM4/29/15
to Kevin Meredith, Spire User List
Any macro that will be used within Spire itself, must go in the macros project due to the separate compilation issue you mentioned. However, there are times where you need access to Spire's types within the macro and don't need to use the macros within Spire (core) (eg fpf.Fuser for FpFilter). In that case, putting them in core makes everything simpler. So, it's really just a technical limitation for either choice :\
Reply all
Reply to author
Forward
0 new messages