05 2022 档案

摘要:import std.stdio; void main() { static if(0 in [0: 0]) //应为真 { writeln(typeof(0 in [0: 0]).stringof); } } //但报错了. 你可以改成: static if((0 in [0: 0]) !is n 阅读全文
posted @ 2022-05-31 09:20 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:如下,tupleof用来对接C. struct Circle { float x, y; float radius; ubyte r, g, b, a; } @nogc nothrow extern(C) void draw_circle ( float cx, float cy, float ra 阅读全文
posted @ 2022-05-30 23:06 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:1,各种h与cpp后缀搞错. 2,好标识/取消标识. 3,资源.h,只添加需要的. 4,微软的资源管理器右键老是崩溃.搞了20年,微软越活越回去了.连个资管都搞不好. 5,rc同样如此,不需要的删除掉. 6,消处与画消窗不一样,因为他们的参数不一样. 7,这里视图是最重要的. 8,主帧调用视图. 9 阅读全文
posted @ 2022-05-30 22:55 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:这里 :需要手动初化.__gshared是正确的方法吗? 这是线程本地存储用途.正如D运行时对dmd的-profile命令行开关那样,可拥有模块级Appender,它为该线程收集数据而无需担心竞争条件. :解锁互斥锁? 仅当每个线程退出并组合结果时,才需要互斥锁.每个static ~this()都可 阅读全文
posted @ 2022-05-30 10:34 zjh6 阅读(16) 评论(0) 推荐(0) 编辑
摘要:库地址 import schlib.newaa; auto myAA = Hash!(string, int)(["hello" : 1, "world" : 2]); void main() { int[string] aa = myAA.asAA; writeln(aa); } 阅读全文
posted @ 2022-05-30 08:58 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:不能在类上引用计数,至少是安全的,因为没有逃逸分析. 想法是编写不暴露字段的类.成员函数控制所有访问. 如下编译: @safe @nogc: class C { C g() => this; } //C f(C c); // 错误 C f(scope C c); // OK //C f(scope 阅读全文
posted @ 2022-05-29 17:38 zjh6 阅读(16) 评论(0) 推荐(0) 编辑
摘要:static int i; void bar(T)(){ static if(is(T == int)) (()@system => 1)(); static if(is(T == float)) i = 42; } void foo(T)(){ bar!T(); } void main()@saf 阅读全文
posted @ 2022-05-28 10:10 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:@safe存在根本性设计缺陷,而DIP1000用来解决它.这不仅是为了新模型,而是要修复现有模型漏洞.如下在无DIP时编译,但DIP1000可检测到: @safe ref int oops1() { int[5] arr; int[] slice = arr[]; return slice[2]; 阅读全文
posted @ 2022-05-28 09:06 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:升级vim 每次升级,都是累,可不升级又不行.升级要用vim官网的稳定版,否则,是不行的.要出错. python要用py32里面的dll,要求名字叫python39.dll,然后放进E:\vim\vim82目录里面. _viminfo也给你覆盖了,我说怎么速度变快了.覆盖了都不讲一声. 什么插件都不 阅读全文
posted @ 2022-05-26 20:35 zjh6 阅读(17) 评论(0) 推荐(0) 编辑
摘要:#If WinActive("ahk_class CabinetWClass")&&(!A_CaretX) n::send {esc}^+{tab} m::send {esc}^{tab} h::send {left} j::send {down} k::send {up} l::send {rig 阅读全文
posted @ 2022-05-25 17:18 zjh6 阅读(120) 评论(0) 推荐(0) 编辑
摘要:;要一个:,还要一个%a%. H(){ GetKeyState,state,LButton,P; return A_Cursor == IBeam && state == D } ;判断是否是输入状态. Loop{ m:=H() ToolTip,%m% %A_CaretX%+200 %A_Caret 阅读全文
posted @ 2022-05-25 16:04 zjh6 阅读(66) 评论(0) 推荐(0) 编辑
摘要:// module a: alias F = extern (C) void function(string param); F fun = someLibLoad!F("name"); assert(fun !is null); // 编译,且运行时工作. // module b: import 阅读全文
posted @ 2022-05-25 14:48 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:import std.stdio; void main()@safe{ void delegate()@safe[] dgList; foreach(i; [1, 2, 3]) { immutable b = i; dgList ~= { writeln(b); };//应该不同. } foreac 阅读全文
posted @ 2022-05-25 09:11 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:class C { void fun() { throw new Exception("oops"); } } class D : C { override void fun() nothrow { } } void main() { D d = new D; C c = new D; d.fun( 阅读全文
posted @ 2022-05-25 08:59 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:extern(C++) class foo { void func() { } } extern(C++) final class bar : foo { override void func() const { } } class foo { public: virtual void func() 阅读全文
posted @ 2022-05-25 08:41 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:import std.stdio: writeln; void foo(uint x) in (x >= 0) {//删除该前条件,因为x为`正`总是`>=0`. writeln(x); } void foo(ushort x) in (x >= 0) { writeln(x); } void ma 阅读全文
posted @ 2022-05-25 08:29 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:struct S { string[] s; } auto foo(string[] s...) //不能用`中`标记`s` { return S(s); //改为 return S(s.dup); } void main() { import std.stdio: writeln; writeln 阅读全文
posted @ 2022-05-25 08:16 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:import std.stdio; import std.algorithm; import std.traits; import std.range; void print(R)(R r) { static assert(isIterable!R); r.each!writeln; } auto 阅读全文
posted @ 2022-05-24 20:40 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:原文 D永远莫用-release发布开关. 它会随机加安全漏洞.它允许一堆随机破坏你代码的坏开关.会删除默认安全设施,而且没有好处. 永远别用它,要优化的话,用-O开关. 我不在乎@safe.我说的是现实世界的安全,比如自动检查边界. 错误的.可在关键位置放.ptr,以局部禁用它,而不是使用全局开关 阅读全文
posted @ 2022-05-24 19:52 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:import std.stdio; @safe: unittest { void delegate()[] dgList; foreach(int i; [1, 2, 3]) { int b = 2; dgList ~= { writeln(b); }; writeln(&b); //报错,d不能取 阅读全文
posted @ 2022-05-24 16:33 zjh6 阅读(46) 评论(0) 推荐(0) 编辑
摘要:import core.memory; import core.stdc.stdlib : malloc, free; import core.lifetime : emplace; T NEW(T, Args...)(auto ref Args args) /*@nogc*/ if (is(T = 阅读全文
posted @ 2022-05-24 16:10 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:如下, T* ptr; if ((ptr = func()) && ...) { ... } // 上面为前,下面为后. T* ptr; if ((ptr = func()) !is null && ...) { ... } // 更可读了. 关键是,要提供迁移路径. 阅读全文
posted @ 2022-05-24 15:35 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:Dcst(){ send {esc} send {ctrl down}{shift down} send {tab 4} send {shift up}{ctrl up} } 是,有点麻烦.折腾了半天,搞出来的. 阅读全文
posted @ 2022-05-24 11:38 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:import std.array, std.exception, std.stdio; mixin template RealizeException() { this(string msg, string file = __FILE__, size_t line = __LINE__) { sup 阅读全文
posted @ 2022-05-24 09:37 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:HasIme(WinTitle="") { ifEqual WinTitle,, SetEnv,WinTitle,A WinGet,hWnd,ID,%WinTitle% DefaultIMEWnd := DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hWnd, 阅读全文
posted @ 2022-05-23 21:55 zjh6 阅读(54) 评论(0) 推荐(0) 编辑
摘要:// 调试断定,可能有性能影响. debug assert(condition); assert(condition); //`普通`断定.对多数应用,即使在`发布`版本中也应`启用`,但`接受`断定`失败`时无`内存安全`性,则可`省略`该选项.应该是最常见的断定. version(D_NoBou 阅读全文
posted @ 2022-05-23 21:30 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:最重要的问题是win11的资源管理经常崩溃. 为此必须找替代方法. 找了几个QTtabbar搞半天,都不成功,最后要安装netfx3.5,真是坑,没人能够安装它.微软明明最擅长的是兼容,结果,在这里完全把祖先本领忘记了. 然后找到extab,非常不错.但是,要改几个映射. 我们用ahk来改一改,不然 阅读全文
posted @ 2022-05-23 10:21 zjh6 阅读(32) 评论(0) 推荐(0) 编辑
摘要:Get-AppxPackage * | Remove-AppxPackage 阅读全文
posted @ 2022-05-21 21:35 zjh6 阅读(5) 评论(0) 推荐(0) 编辑
摘要:微软自身无法正确安装输入法了. 只有借助第3方工具. 微软太多垃圾程序访问你的输入法了. 删又删不掉的垃圾. 不要去微软的设置,微软的设置就是垃圾. 微软太多垃圾了. 用IMEManager_v1.0或输入法调整工具来删除自带的默认,并置极点为默认,然后小鸭作为后备. 阅读全文
posted @ 2022-05-21 20:32 zjh6 阅读(41) 评论(0) 推荐(0) 编辑
摘要:注意,不要随意卸载极点五笔.微软的东西太恶心. 输入法都不好用. 用这个 ime工具 输入法管理工具. 这里删除微软自带的 阅读全文
posted @ 2022-05-21 18:42 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:原文 我想暂停它以重复下一次迭代 import std.stdio; import modules.monitors; //我的模块 import core.thread; int main(string[] args) { string path = "mswitch.log"; if (args 阅读全文
posted @ 2022-05-21 16:07 zjh6 阅读(17) 评论(0) 推荐(0) 编辑
摘要:nnoremap ex :q!<CR> "用两个单词来退出" tnoremap <esc> <C-W>N "映射终端为普通模式,直接退出,z退出,已经是普通模式" tnoremap <esc> <C-\><C-N> "这个在win10与win11不一样? 非常奇怪,在win11里面的映射不一样. 有 阅读全文
posted @ 2022-05-20 15:50 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:let height = get(g:, "dispatch_quickfix_height", 5) 这是1356行.dispatch_quickfix_height设置高度. 这里有. :3 split file. ctrl+W 4+加高度. execute (mods) 'copen' hei 阅读全文
posted @ 2022-05-20 14:40 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:显式源和目标类型的强制转换来解决 auto cast_from(From,To,Real)(Real a) { static if (is (From==Real)) return cast(To) a; else pragma(msg, "错误类型"); } void main() { impor 阅读全文
posted @ 2022-05-20 10:28 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:用法 Vim编译器系统核心是类似:grep运行构建工具并解析产生错误的:make命令.默认构建工具当然是.make,但你可用:compiler.有很多内置编译器,它们不仅仅是编译.另外,也可自己制作. 看从查看dispatch.vim的:make包装器的:Make开始,然后转向更高级抽象. 前台构建 阅读全文
posted @ 2022-05-19 21:44 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:简介 利用Vim编译器系统的强大功能而不受同步限制. 命令 dispatch-:Make :Make[参数],使用当前的:compiler设置,在前台分发构建.适配器策略各不相同,但目标是不窃取焦点,就实现可见性.构建后,加载结果到quickfix列表并调用:cwindow.此命令适合如"构建 此文 阅读全文
posted @ 2022-05-19 16:27 zjh6 阅读(22) 评论(0) 推荐(0) 编辑
摘要:if ('A' <= c && c <= 'Z') c = c | 0x20; 这没问题, a = (b < c) ? 8 : 3; 要求极为整,才能转化为类似: a = 3 + (b < c) * 5; 分支代码,在GPU中用,并在安全代码中用来抵抗时间攻击. 在SIMD指令中,也会看见,它设置所 阅读全文
posted @ 2022-05-19 14:56 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:这里 按GC拥有对象构造类对象来,写这些. 准则: 论坛中看到了以下几个观点. 1,(这是复杂问题.)类没有析构器;应该叫终结者. 2,不要在类析构器中从GC分配内存.(如,writeln可能适合简单类型,但writefln或format则不行.) 3,因为可能已析构,不要使用类析构器中GC拥有成员 阅读全文
posted @ 2022-05-19 11:34 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:不能有匿名构字面作为赋值右端,使我不高兴. 可能不会弃用或删除结构化大括号初化.会破坏太多现有代码,而收益太少. 实现DIP1030后,D的构字面实现,与C99一样的复合字面功能(也不是匿名的,要求用类似强制转换语法来指定类型) 在dmd的ImportC中加"带类C"的C++接口. 不会删除{}初化 阅读全文
posted @ 2022-05-19 09:50 zjh6 阅读(19) 评论(0) 推荐(0) 编辑
摘要://~/.vim/compiler/xmllint.vim: if exists("current_compiler") finish endif let current_compiler = "xmllint" setlocal makeprg=xmllint\ --valid\ --noout\ 阅读全文
posted @ 2022-05-19 00:14 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要::Make而不是:make 在Vim8或NeoVim中,你不能用:make异步运行内置命令. 你必须取'makeprg'的值,并插入vim8的job_start()或neovim的jobstart(). 我个人喜欢插件的方便性,这些插件可处理vim8/neovim的差异,解析结果并插入它到quick 阅读全文
posted @ 2022-05-18 22:52 zjh6 阅读(31) 评论(0) 推荐(0) 编辑
摘要:原文 make是同步工具,可丢弃了. 可用:h:terminal或:h term_start()在vim中异步.这里用term_start. Make位置 目标 1,异步make,quickfix后更新,用户可像终端中的make一样,看到make的进度. 2,如果正确,则显示成功make消息,不会警 阅读全文
posted @ 2022-05-18 22:34 zjh6 阅读(25) 评论(0) 推荐(0) 编辑
摘要:先改为: call s:map('n', '.m<CR>', '<SID>:.Make<CR>') call s:map('n', '.m<Space>', '<SID>:.Make<Space>') call s:map('n', '.m!', '<SID>:.Make!') call s:map 阅读全文
posted @ 2022-05-18 22:04 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:这里 就这样吧,常见自动阅读全文.避免折叠,烦得很. 为什么要用它,因为有时,网站老是在变,烦得很.烦烦烦. 阅读全文
posted @ 2022-05-18 11:41 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:原文 import std.stdio; enum Foo { bar } int main(string[] args) { writefln("调试: %d\n", &(Foo.bar)); return 0; } 错误:bar无法修改清单常量. 它们都不是左值.等价结构是"静态 常和不变".在 阅读全文
posted @ 2022-05-18 11:25 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:原文 输入安装位置,来选择usb. void writeusb() { writeln("驱动列表"); auto mounts = executeShell("cat /proc/mounts | grep media"); writeln(mounts.output); writef("输入位置 阅读全文
posted @ 2022-05-17 09:25 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:如果使用两个包含共同标头类型的C标头,则会这样.考虑以下文件: // foo_def.h typedef struct Foo *FooRef; // maker.h #include "foo_def.h" FooRef make_foo(void); // freer.h #include "f 阅读全文
posted @ 2022-05-17 09:02 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:原文 考虑不变构: 不变 struct S { } 定义比如用Unqual从类型中去除不变的模板特化. mixin template Foo(T) { static assert(is(S == T)); } mixin template Foo(T: 不变 U, U) { pragma(msg, 阅读全文
posted @ 2022-05-16 22:21 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:d可保证编译时执行下面吗? auto genFactorials(int n) { auto result = new int[n]; result[0] = 1; foreach (i; 1 .. n) { result[i] = result[i - 1] * i; } return resul 阅读全文
posted @ 2022-05-16 16:35 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:总之,区别在于构是值类型,类是引用类型.这非常重要. 在C++中,结构可按值或引用类型设计.但是C++不承认差异,因此可按值传递引用,这会导致各种问题.你会看到C++迷惑,因为设计者不知道其中区别,并且脚踏两边.该混淆的常见示例是放入虚函数,但忽略了使析构器为虚. D严格区分两者,使其既可自我记录, 阅读全文
posted @ 2022-05-16 16:14 zjh6 阅读(18) 评论(0) 推荐(0) 编辑
摘要:原文 最近介绍了ImportC.我做了以下事情: 1)从libplot文档中复制示例代码并粘贴到D文件中. 2),添加以下行到文件中: import plot; 注意:为此,在Makefile中添加了以下行: plot.i: plot.c Makefile gcc -I /usr/include - 阅读全文
posted @ 2022-05-16 11:27 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:#include "资源.h" #include "winres.h" LANGUAGE LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED #pragma code_page(936) //语言 IDD_ABOUT DIALOG DISCARDABLE 0, 0, 18 阅读全文
posted @ 2022-05-15 23:34 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:hi KzBf guibg=lightRed match KzBf /\s\+$\|\t/ "上面两行为空白,这个很怪的,上下两行不能反 要这样来高亮你所需要的东西 阅读全文
posted @ 2022-05-15 18:06 zjh6 阅读(7) 评论(0) 推荐(0) 编辑
摘要:原文 return scope,scope return和return的区别? 为何构中void* ptr改变了scope return的效果. @safe: struct A{ int val; //void* ptr; int* test() scope return{ return &this 阅读全文
posted @ 2022-05-15 16:29 zjh6 阅读(66) 评论(0) 推荐(0) 编辑
摘要:如果@system和__metadata是单独的注解,你会得到:@system规则__metadata规则. 变量是@system原因很多,因为它只是收集了不安全的来源.__metadata是考虑添加到语言中的新的此类源. 因为DIP1035并不改变变量类型. 编译器仍跟踪所有这些,并使其作为注解部 阅读全文
posted @ 2022-05-14 20:10 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:原文 import std; import __stdin; void main() { writeln(MY_VALUE); } echo "enum MY_VALUE = 123;" | dmd - -run main.d 不仅用于定义常量;还可这样注入任意D代码片到编译中.当然,这不*理想*. 阅读全文
posted @ 2022-05-14 11:40 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 void fn() @safe { () @trusted { x = new int; }();//安全了? *x = 10; // 错误,不能在`@安全`代码中访问`@系统`变量 } //x为外部 但,不仅是上面,还可这样: extern int* x; // 推导为@system @sy 阅读全文
posted @ 2022-05-13 21:28 zjh6 阅读(9) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示