Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:37:14+00:00 2026-06-11T01:37:14+00:00

I might be using incorrect terminology, but here is example what I would like

  • 0

I might be using incorrect terminology, but here is example what I would like to achieve. Lets say I have the following macro:

def generateField[T]: AnyRef =
  macro generateFieldImpl[T]

def generateFieldImpl[T: c.AbsTypeTag](c: Context): c.Expr[AnyRef] = {
/**
 * here I'm looking at the type T by reflection to see now many members it has
 * and based on that I'm generating TupleN[Array[Byte], ...](null, ...)
 * where N is number of members in class represented by type T
 */
}

I’m planning to use only case classes as T.

When I use this macro with case class it works great, but now I’d like to add a level of abstraction:

trait WithGeneratedField[T] {
  val _myField = generateField[T]
}

The problem I’m having is that macro gets expanded when trait is being declared and at that point T is known as an abstract type ‘T’. Is there any way to defer macro expansion until I mix-in this trait with something concrete? For instance:

case class MyClass(a: String, b: Int) extends WithGeneratedField[MyClass]

At the end my goal is to use macro to add a generated field to a case class. Maybe there is a better way of doing that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:37:16+00:00Added an answer on June 11, 2026 at 1:37 am

    I would be surprised if this turns possible in 2.10.0.

    With macro types or macro annotations (http://scalamacros.org/future.html) it should be pretty straightforward. We’re going to work on these new flavors of macros as soon as we release 2.10.0-final, but it’s hard to predict the ETA. Maybe winter of 2012 – spring of 2013.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I might have my terminology incorrect in the title using the word singleton. I
I might just be using the wrong keywords on Google, but what I have
I'm trying to understand how parallelism might work using PLINQ, given delayed execution. Here
This might be simple but I am new to Oracle. I am using Oracle
What might be the possible cause of the following? I am using an autocomplete
Why might using a long long in C or C++ be a bad thing?
How might someone fill in an input field with some text using jquery by
I think this might be a problem with the theme I'm using ( Nitobe
We are considering using Cassette in our asp.net web application which might be accessed
I know this might sound easy. I thought about using the first dot(.) which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.