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

  • Home
  • SEARCH
  • 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 894619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:25:19+00:00 2026-05-15T14:25:19+00:00

This doesn’t work in D: void doSomething(auto a, auto b){ // … } I’m

  • 0

This doesn’t work in D:

void doSomething(auto a, auto b){
    // ...
}

I’m just curious, will this ever work? Or is this just technically impossible? (Or just plain stupid?)

In anyway, can this be accomplished in any other way? I suppose I could use the ... and look through the argument list, but I’m kinda making a library for lazy newbie people and want them to be able to create functions easily without really caring about data types. I’m playing with the idea of creating a struct called var like

struct var{
   byte type;
   void* data
   // ...
}

// and overload like all operators so that a lazy devver can do

var doSomething(var a, var b){
   if(a == "hello")
       b = 8;
   var c = "No.:" ~ b ~ " says:" ~ a; 
   return c;
}

But my head is already starting to hurt right there. And, I’m kinda feeling I’m missing something. I’m also painfully aware that this is probably what templates are for… Are they? From the little I know, a template would look like this (?)

void doSomething(T, U)( T a, U b){
   // ...
}

But now it doesn’t look so clean anymore. Maybe I’m getting all this backwards. Maybe my confusion stems from my belief that auto is a dynamic type, comparable to var i javascript, but when in reality, it’s something else?

And if it isn’t a dynamic type, and this is probably a whole other topic, is it possible to create one? Or is there maybe even an open source lib available? A liblazy maybe?

(PS. Yeah, maybe the lazy devver is me : )

  • 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-05-15T14:25:20+00:00Added an answer on May 15, 2026 at 2:25 pm

    I’ll just add that something close to your idea of runtime type polymorphism (the var structure) is already implemented in the std.variant module (D2 only).

    Also, technically auto is really a keyword that does nothing – it’s used where you need a type modifier without a type. If you don’t specify a type, D will infer it for you from the initialization expression. For example, all of these work:

    auto i = 5;
    const j = 5;
    static k = 5;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've written a decent tutorial on this. To summarize: Include… May 16, 2026 at 11:40 pm
  • Editorial Team
    Editorial Team added an answer You can't directly name the result of a join. One… May 16, 2026 at 11:40 pm
  • Editorial Team
    Editorial Team added an answer I took me a week, but I got it. #####… May 16, 2026 at 11:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This doesn't work panel1.layout: layout [ offset: 0x0 yuml-image: image img ] panel2.layout: layout
I'm not sure why this doesn't work: scala> case class Loader(n: String, x: String,
everyone, i have no idea why this doesn't work hopefully someone here can help
This doesn't seem possible in VB.NET with properties since the property statement itself must
I'm a little confused as to why this doesn't give an error. I found
Hey all, I am not quite getting why this doesn't seem to be working.
this is what i have right now Drawing an RSS feed into the php,
For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I'm looking for suggestions for debugging... If you view this site in Firefox or

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.