Re: Why use while if only iterating once ?
Thankyou. As the great Gump's mother said, stupid is as stupid does.
Why use while if only iterating once ?
while (1) { FLAGS f; switch (*p) { case 'U': case 'u': f = FLAGS.unsigned; goto L1; case 'l': f = FLAGS.long_; error("lower case integer suffix 'l' is not allowed. Please use 'L' instead"); goto L1; case 'L': f = FLAGS.long_; L1: p++; if ((flags & f) && !err) { error("unrecognized token"); err = true; } flags = cast(FLAGS)(flags | f); continue; default: break; } break; } The last break statement prevents the loop from returned for a second iteration. Then why use a while ?
Re: Dub dependency conflict resolution
On Sunday, 7 October 2018 at 05:24:37 UTC, Bauss wrote: On Saturday, 6 October 2018 at 17:50:57 UTC, Venkat wrote: I couldn't find any documentation on how dub resolves dependency conflicts. Here is my situation. Package A has a dependency on package B-1.0.0 which has a dependency on package C-1.0.0. Package A declares a dependency on package C-1.0.1 How does dub behave in this situation. From what I see, it always resolves C-1.0.0 and completely ignores the dependency on C-1.0.1. Is there a way to force the usage of C-1.0.1, like maven's exclude tags ? NOTE: That description is not meant as an insult. Most people here understand what a dependency conflict is. I am merely trying to put my thought in writing. You should get a dub selection file or something like that when you build, which will be located in the root of your project. You can control versions explicit in that. That was it. Once I deleted dub.selections.json, it picked up explicitly declared version. Still it would be nice to learn how dub deals with dependency conflicts. Thankyou.
Dub dependency conflict resolution
I couldn't find any documentation on how dub resolves dependency conflicts. Here is my situation. Package A has a dependency on package B-1.0.0 which has a dependency on package C-1.0.0. Package A declares a dependency on package C-1.0.1 How does dub behave in this situation. From what I see, it always resolves C-1.0.0 and completely ignores the dependency on C-1.0.1. Is there a way to force the usage of C-1.0.1, like maven's exclude tags ? NOTE: That description is not meant as an insult. Most people here understand what a dependency conflict is. I am merely trying to put my thought in writing.
Re: What does std.traits.hasAliasing do
Thankyou.
Re: What does std.traits.hasAliasing do
On Sunday, 29 July 2018 at 01:05:19 UTC, Venkat wrote: struct SomeStruct { string p; string q; string[] pq; } Session session = req.session; session.get!SomeStruct("registerBody"); /home/venkat/.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/session.d(83,3): Error: static assert: "Type SomeStruct contains references, which is not supported for session storage." vibe.d session won't let me put in a simple struct with an array or an associative array. session.put calls std.traits.hasAliasing which is returning true when I have either an array or an associative array. I looked through the std.traits.hasAliasing code. I can't make a whole lot of sense there. The hasAliasing function documentation says as long as the array or associative array are not immutable it should return true. Since session.put does !hasAliasing I changed string[] to immutable, that throws a whole lot of other compilation error messages. What is hasAliasing doing ? Posted the wrong code. Fixed it above. Reposting below for clarity. For the record both session.get and session.put call hasAliasing. struct SomeStruct { string p; string q; string[] pq; } Session session = req.session; session.get!SomeStruct("registerBody");
What does std.traits.hasAliasing do
struct SomeStruct { string p; string q; string[] pq; } ErrorMessage[] pq; session.set("registerBody", pq); /home/venkat/.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/session.d(83,3): Error: static assert: "Type SomeStruct contains references, which is not supported for session storage." vibe.d session won't let me put in a simple struct with an array or an associative array. session.put calls std.traits.hasAliasing which is returning true when I have either an array or an associative array. I looked through the std.traits.hasAliasing code. I can't make a whole lot of sense there. The hasAliasing function documentation says as long as the array or associative array are not immutable it should return true. Since session.put does !hasAliasing I changed string[] to immutable, that throws a whole lot of other compilation error messages. What is hasAliasing doing ?
Re: Request scoped information in Vibe.d
On Sunday, 22 July 2018 at 08:43:23 UTC, Johannes Loher wrote: On Sunday, 22 July 2018 at 06:21:40 UTC, Venkat wrote: How do I make variables available to diet templates ? Java has request.setAttribute. Vibe.d's HTTPServerRequest has params and queryString. But by the looks of it, neither one of them is created for the purpose of temporary storage in the request. Where do I store request scoped information ? What is your usecase? If you simply want to pass a variable to a diet template, just pass it as a template parameter to render: /* ... */ int myVar = 42; render!("mytemplate.dt", myVar); /* ... */ Then in mytemplate.dt, you can do something like: p The best number ever is #{ myVar } That is what I want to do. But what if I am redirecting the user with some form errors ? In that case I am not using render!.
Request scoped information in Vibe.d
How do I make variables available to diet templates ? Java has request.setAttribute. Vibe.d's HTTPServerRequest has params and queryString. But by the looks of it, neither one of them is created for the purpose of temporary storage in the request. Where do I store request scoped information ?
Re: Is there any tool that will auto publish my changes.
Thankyou Ali. Timoses. I did try DiamondMVC for a bit, but I found that there is more help out there for Vibe.d. So I reverted back to using that. And the Dependency Injection in Diamond MVC brings all the obscurity that spring has which makes debugging more of a guessing game than a logical derivation. My application isn't that big, so compile times aren't unbearable yet. And server restart, boy server starts under 10 seconds, unimaginable in java world !!! Static files are already reloaded automatically on edit. But edit, compile, restart cycle times do add up over a period. Not to mention the entire process is redundant and therefore a good candidate for automation. Anyway, thankyou for the insight. I'll have to admit I am not equipped with the knowledge to whip something up like that myself (yet ?). Absence of such a tool nevertheless doesn't diminish the pleasure of developing with D, dub, vibe.d, DDBC and HibernateD. Thanks to developers of those tools. Thanks evilrat.
Re: Is there any tool that will auto publish my changes.
An extension to the question. Is something like auto publish that even possible ? Or the dumb guy from java world don't know what he talkin' 'bout ?
Is there any tool that will auto publish my changes.
I am writing a simple vibe.d app. The following is what I do right now. - I make changes. - build - Restart the server. Is there any tool that will auto publish my changes as I save them ? I am using Visual Studio Code. Thanks Venkat
Re: How to enable verbose logging during application run
Thankyou.
Re: How to enable verbose logging during application run
Sorry posted the above message by accident. I am running a vibed app using `dub` command. But it produces no logging what so ever when requests are made. The server returns http error codes but it doesn't log anything to the console. How do I make it show me a lot more detail than it is doing now ? For example, in a Java webapp, one would change the logging level to debug if a logging library is configured.
How to enable verbose logging during application run
I am running a vibed app using `dub` command. But it produces no logging what so ever when re
Re: SegFault with HibernateD
On Saturday, 13 January 2018 at 06:18:43 UTC, Ali Çehreli wrote: On 01/12/2018 06:50 PM, Venkat wrote: > Sorry about all these posts. Wish there were an edit button. That's ok. :) These are actually newsgroups (see NNTP protocol). Newsgroups don't have any edit functionality. The "forum" is just a web interface to newsgroups. Ali Oh! ok, that makes sense. TY.
Re: SegFault with HibernateD
Sorry about all these posts. Wish there were an edit button. I meant PreparedStatement in mysqlddbc driver, not HibernateD.
Re: SegFault with HibernateD
I think there is a bug with PreparedStatement class in HibernateD. ddbc fails when I use a PreparedStatement. The code below shows that. I will create an issue with HibernateD. int main(string[] args) { string url = "mysql://localhost:3306/webmarx?user=webmarx_dev,password=webm@rx"; // creating Connection auto conn = createConnection(url); scope(exit) conn.close(); // creating Statement auto stmt = conn.createStatement(); scope(exit) stmt.close(); PreparedStatement prepStatement = conn.prepareStatement("SELECT * FROM preferences_wm ORDER BY id"); scope(exit) prepStatement.close(); ResultSet rs = prepStatement.executeQuery(); writeln(rs.getFetchSize()); return 0; }
Re: SegFault with HibernateD
On Friday, 12 January 2018 at 08:55:13 UTC, Rene Zwanenburg wrote: Hard to guess what the issue is, I'd attach a debugger to see where it crashes. It fails at the sql() method in Command struct in mysql-native-1.1.4/mysql-native/source/mysql/commands.d. This is what gdb says when I do a disp _sql. 1: _sql = I'm sorry I am new to systems programming, would that mean _sql is null ?
Re: SegFault with HibernateD
On Friday, 12 January 2018 at 12:41:34 UTC, Mike Parker wrote: I see now. I glossed right over that execution output. On Windows, I don't recall ever seeing a dub exception from dub from a segfault. Just checked by accessing a null pointer and there's nothing thrown from dub. Is that a Linux thing? Thankyou for the reply. Yes I am running the app on Linux. I will report the issue.
SegFault with HibernateD
I get a SegFault with the main method below which uses HibernateD . The second main method which uses ddbc just works fine. What is wrong with the first main method ? I have attached the error at the bottom although I don't think it says much. This method uses HibernateD int main() { // setup DB connection string url = MySQLDriver.generateUrl("localhost", 3306, "test"); string[string] params = MySQLDriver.setUserAndPassword("test", "test"); DataSource ds = new ConnectionPoolDataSourceImpl(new MySQLDriver(), url, params); // create metadata from annotations EntityMetaData schema = new SchemaInfoImpl!(Preferences); // create session factory Dialect dialect = new MySQLDialect(); SessionFactory factory = new SessionFactoryImpl(schema, dialect, ds); scope(exit) factory.close(); auto conn = ds.getConnection(); scope(exit) conn.close(); // create session Session sess = factory.openSession(); scope(exit) sess.close(); Query q = sess.createQuery("select p from Preferences p"); Preferences[] list = q.list!Preferences(); return 0; } The method below uses ddbc. int main(string[] args) { string url = "mysql://localhost:3306/test?user=test,password=test"; // creating Connection auto conn = createConnection(url); scope(exit) conn.close(); // creating Statement auto stmt = conn.createStatement(); scope(exit) stmt.close(); // reading DB auto rs = stmt.executeQuery("SELECT * FROM preferences_wm ORDER BY id"); writeln(rs.getFetchSize()); return 0; } This is the error. Running ./bin/hibernated-test Program exited with code -11 Full exception: object.Exception@source/dub/generators/build.d(530): Program exited with code -11 /home/vagrant/old-dmd/dmd2/linux/bin64/../../src/phobos/std/exception.d:420 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0x8d036c] /home/vagrant/old-dmd/dmd2/linux/bin64/../../src/phobos/std/exception.d:388 pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x8defcd] source/dub/generators/build.d:530 void dub.generators.build.BuildGenerator.runTarget(dub.internal.vibecompat.inet.path.Path, const(dub.compilers.buildsettings.BuildSettings), immutable(char)[][], dub.generators.generator.GeneratorSettings) [0x97b1c9] source/dub/generators/build.d:110 void dub.generators.build.BuildGenerator.performPostGenerateActions(dub.generators.generator.GeneratorSettings, const(dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]])) [0x977541] source/dub/generators/generator.d:118 void dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings) [0x9805a0] source/dub/dub.d:494 void dub.dub.Dub.generateProject(immutable(char)[], dub.generators.generator.GeneratorSettings) [0x8918e0] source/dub/commandline.d:789 int dub.commandline.GenerateCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x857579] source/dub/commandline.d:821 int dub.commandline.BuildCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x857913] source/dub/commandline.d:849 int dub.commandline.RunCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x857b23] source/dub/commandline.d:239 int dub.commandline.runDubCommandLine(immutable(char)[][]) [0x853647] source/app.d:14 _Dmain [0x84fc27]
Re: -L--demangle=dlang doesn't work
Yes, thanks Mike. I have 2.24 installed. Now I have to figure out how I can upgrade binutils without a distro upgrade. :)
-L--demangle=dlang doesn't work
Why does gcc say "unknown demangling style `dlang'" ? Do I need GDC for demangling to work ? 85198AB7DE24894B5F742FBD5/libvibe-d_data.a /home/venkat/.dub/packages/vibe-d-0.8.2/vibe-d/utils/.dub/build/library-unittest-linux.posix-x86_64-dmd_2077-B9AE30DD34FDC5ADDE81E208F10DF014/libvibe-d_utils.a -L--no-as-needed -L--demangle=dlang -L-lsqlite3 -L-levent_pthreads -L-levent -L-lssl -L-lcrypto -L-ldl -g /usr/bin/ld: unknown demangling style `dlang' collect2: error: ld returned 1 exit status Error: linker exited with status 1 FAIL .dub/build/webmarx-test-application-unittest-linux.posix-x86_64-dmd_2077-C5DB1ABAED0A1191C5B2ACAFDC70EAC6/ webmarx-test-application executable dmd failed with exit code 1. Full exception: object.Exception@source/dub/compilers/compiler.d(115): dmd failed with exit code 1.
Re: A DUB Case Study: Compiling DMD as a Library
I did a fresh clone of dmd and added that as a dependency. That fixed it. Should've thought of it !! Thankyou.
Re: A DUB Case Study: Compiling DMD as a Library
This is regarding the latest D blog post. Jacob Carlborg is here, so I figured I'd post it. https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/#comment-2922 Simply changing the targetType from library to dynamicLibrary breaks the code. What is going on with it ? --dub.sdl-- name "dmd-dub-test" description "Test of the DMD Dub package" license "BSL 1.0" sourcePaths "." targetType "library" dependency "dmd" path="../DSource/dmd/" --end dub.sdl-- -- output -- venkat@venkat-U46E /d/Documents/NetbeansProjects/dmd-test $ dub build Performing "debug" build using dmd for x86_64. -- end output -- --dub.sdl-- name "dmd-dub-test" description "Test of the DMD Dub package" license "BSL 1.0" sourcePaths "." targetType "dynamicLibrary" dependency "dmd" path="../DSource/dmd/" --end dub.sdl-- Performing "debug" build using dmd for x86_64. dmd ~stable: building configuration "library"... ../DSource/dmd/src/ddmd/scanmscoff.d(180,10): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(181,10): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(182,10): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(183,10): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(184,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(185,15): Error: undefined identifier BYTE ../DSource/dmd/src/ddmd/scanmscoff.d(185,15): Error: undefined identifier BYTE ../DSource/dmd/src/ddmd/scanmscoff.d(187,14): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(187,14): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(188,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(189,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(190,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(196,11): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(197,11): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(198,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(199,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(200,11): Error: undefined identifier DWORD ../DSource/dmd/src/ddmd/scanmscoff.d(201,11): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(202,11): Error: undefined identifier WORD ../DSource/dmd/src/ddmd/scanmscoff.d(225,24): Error: undefined identifier BYTE dmd failed with exit code 1.
Re: Dub generates a library file that is larger in size than the one built on command line.
TY Mike, that explains it. Thanks Ivan.
Re: Dub generates a library file that is larger in size than the one built on command line.
dub build --vverbose That is the command I used. Would it be right to assume that -g is being added because --vverbose ? The reason I ask is the file size is about the same when I run the below command. dub build
Dub generates a library file that is larger in size than the one built on command line.
The following is the command output by dub with --vverbose switch. It generates a file which is 6094400 bytes in size dmd -lib -of.dub/build/library-debug-linux.posix-x86_64-dmd_2077-7BB682AB55F152616E128DD715E887DF/libdjni.a -debug -g -w -version=Have_djni -Isource/ source/app.d source/jni/JavaArray.d source/jni/JavaClass.d source/jni/JavaEnv.d source/jni/JavaField.d source/jni/JavaMethod.d source/jni/JavaObject.d source/jni/JavaString.d source/jni/JavaVM.d source/jni/JniHelper.d source/jni/JniProxy.d source/jni/jni.d source/jni/package.d -vcolumns The below command generates a library file of size 3586152 bytes. dmd -oflibDJni.a -lib -H -Hdimport/jni source/jni/*.d so the file generated by dub is almost twice in size. Why such a difference ? What does dub include in the generated file ?
Dub generate import files
dmd has the -H and -Hd switches. Does dub have any setting to make it generate D interface files ?
Re: Code Review
On Sunday, 10 December 2017 at 07:03:30 UTC, Venkat wrote: Can anybody take a look at this checkin ? The import files are a noise, please ignore them and take a look at the *.d files. Changes I made. - Tried to remove __va_argsave as it doesn't compile with it. - Tried to replace no arg opCall() with a factory function. https://bitbucket.org/vra5107/djni/pull-requests/1/code-now-compiles-removed-__va_argsave-and/diff Thanks in advance Venkat I should add that the source builds fine and I was able to write a couple of rudimentary programs using the library built from the sources.
Code Review
Can anybody take a look at this checkin ? The import files are a noise, please ignore them and take a look at the *.d files. Changes I made. - Tried to remove __va_argsave as it doesn't compile with it. - Tried to replace no arg opCall() with a factory function. https://bitbucket.org/vra5107/djni/pull-requests/1/code-now-compiles-removed-__va_argsave-and/diff Thanks in advance Venkat
Re: std.conv.to!string refuses to convert a char* to string.
Thank you, core.runtime.Runtime.initialize() fixed the issue. I am now able to use to!string as well. I found your posts and Ali Çehreli's posts on this subject. I think I have some understanding now.
Re: std.conv.to!string refuses to convert a char* to string.
Thanks for the quick response. std.string.fromStringz did the trick. I am not sure what was the deal with to!string.
std.conv.to!string refuses to convert a char* to string.
I am trying out the DJni library (https://github.com/Monnoroch/DJni). For some reason std.conv.to!string doesn't want to convert a char* to a string.The lines below are taken from the log. I see that the last frame is at gc_qalloc. I am not sure why it failed there. Can anybody elaborate on what is going on here ? Thanks in advance. 91 92 93 Stack: [0x7f749dfd9000,0x7f749e0da000], sp=0x7f749e0d8600, free space=1021k 94 Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) 95 C [libPrompt.so+0x6b0cc] gc_qalloc+0x2c 96 C [libPrompt.so+0x7bf18] _D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_+0xec 97 C [libPrompt.so+0x6c2fa] _d_newarrayU+0x86 98 C [libPrompt.so+0x593a7] _D6object__T4_dupTxaTaZQlFNaNbAxaZAa+0x1f 99 C [libPrompt.so+0x59384] _D6object__T11_trustedDupTxaTaZQtFNaNbNeAxaZAa+0x20 100 C [libPrompt.so+0x59360] _D6object__T3dupTaZQhFNaNbNdNfAxaZAa+0x20 101 C [libPrompt.so+0x5932a] _D3std4conv__T6toImplTAyaTPxaZQqFQhZ9__lambda2MFNaNbZQBf+0x3e 102 C [libPrompt.so+0x592ea] _D3std4conv__T6toImplTAyaTPxaZQqFNaNbQlZQs+0x16 103 C [libPrompt.so+0x592d1] _D3std4conv__T2toTAyaZ__TQlTPxaZQsFNaNbQlZQy+0x9 104 C [libPrompt.so+0x59289] Java_Prompt_getLine+0x61 105 j Prompt.getLine(Ljava/lang/String;)Ljava/lang/String;+0 106 j Prompt.main([Ljava/lang/String;)V+11 107 v ~StubRoutines::call_stub 108 V [libjvm.so+0x690c66] JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x1056 109 V [libjvm.so+0x6d2072] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x362 110 V [libjvm.so+0x6ee8da] jni_CallStaticVoidMethod+0x17a 111 C [libjli.so+0x7bdf] JavaMain+0x81f 112 C [libpthread.so.0+0x8184] start_thread+0xc4 113 114 Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) 115 j Prompt.getLine(Ljava/lang/String;)Ljava/lang/String;+0 116 j Prompt.main([Ljava/lang/String;)V+11