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 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

Related Questions

this doesn't work: void function(char* var) { var = (char*) malloc (100); } int
I suppose this doesn't really matter, I'm just curious. If the difference between dictionary
I was curious why this doesn't work: const int ASSIGN_LEFT = 1; const int
This doesn't work: int number = 1; String numberstring = IntToString(number); I get The
This doesn't seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m)
This doesn't work: INSERT INTO users (username, password) VALUES (Jack,123) WHERE id='1'; Any ideas
This doesn't work: $to = 'myemail@gmail.com'; $from = 'test@test.com'; $subj = 'test'; $message =
This doesn't seem to work in jqTouch or iUI. But I know it's possible
This doesn't work: $F = <div class='f'>F</div>; $d = <div class='d'>d</div>; $Y = <div
This doesn't seem to work. Is it possible? public interface IInterface1 {} public interface

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.